Bug 45061

Summary: Power consumption higher after resume, probably vgaswitcheroo/radeon related
Product: Drivers Reporter: Alessandro Pignotti (alexpigna.dev)
Component: Video(DRI - non Intel)Assignee: drivers_video-dri
Status: RESOLVED DUPLICATE    
Severity: normal CC: chris, peter, santiago.mola
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.2, 3.4, 3.5 Subsystem:
Regression: No Bisected commit-id:
Attachments: lspci -vvv

Description Alessandro Pignotti 2012-07-23 10:15:49 UTC
Created attachment 75941 [details]
lspci -vvv

I have an hybrid graphics Sony VAIO laptop, with the usual intel integrated+radeon discrete cards. On startup I disable the radeon card using vgaswitcheroo. 

I noticed that the power consumption, as reported in

/proc/acpi/battery/BAT1/state

gets higher when I resume my laptop from suspend to RAM. I strongly suspect that this is related to a bug in vgaswitcheroo or the radeon driver, since the power used after resume is consistent with the power used when the discrete video card is not off. My guess is that the card is powered by default when the system comes up from suspend, while the kernel believes it's still powered off.

Before resume I made sure the discrete card was off by using

sudo bash -c "echo OFF > /sys/kernel/debug/vgaswitcheroo/switch"

At resume, with high power consumption, the state is reported as expected:

sudo cat /sys/kernel/debug/vgaswitcheroo/switch
0:IGD:+:Pwr:0000:00:02.0
1:DIS: :Off:0000:01:00.0

Still, if I run:

sudo bash -c "echo ON > /sys/kernel/debug/vgaswitcheroo/switch"

It takes a few seconds, and from dmesg I can see errors from the radeon driver.
[ 9450.115590] radeon: switched on
[ 9450.115618] radeon 0000:01:00.0: enabling device (0000 -> 0003)
[ 9450.115634] radeon 0000:01:00.0: setting latency timer to 64
[ 9450.115644] radeon 0000:01:00.0: GPU softreset 
[ 9450.115649] radeon 0000:01:00.0:   GRBM_STATUS=0xFFFFFFFF
[ 9450.115654] radeon 0000:01:00.0:   GRBM_STATUS_SE0=0xFFFFFFFF
[ 9450.115660] radeon 0000:01:00.0:   GRBM_STATUS_SE1=0xFFFFFFFF
[ 9450.115665] radeon 0000:01:00.0:   SRBM_STATUS=0xFFFFFFFF
[ 9450.343133] radeon 0000:01:00.0: Wait for MC idle timedout !
[ 9450.343137] radeon 0000:01:00.0:   GRBM_SOFT_RESET=0x00007F6B
[ 9450.343245] radeon 0000:01:00.0:   GRBM_STATUS=0xFFFFFFFF
[ 9450.343250] radeon 0000:01:00.0:   GRBM_STATUS_SE0=0xFFFFFFFF
[ 9450.343255] radeon 0000:01:00.0:   GRBM_STATUS_SE1=0xFFFFFFFF
[ 9450.343260] radeon 0000:01:00.0:   SRBM_STATUS=0xFFFFFFFF
[ 9455.340458] [drm:atom_op_jump] *ERROR* atombios stuck in loop for more than 5secs aborting
[ 9455.340473] [drm:atom_execute_table_locked] *ERROR* atombios stuck executing CDDC (len 62, WS 0, PS 0) @ 0xCDF8
[ 9455.340481] [drm:atom_execute_table_locked] *ERROR* atombios stuck executing BB16 (len 1036, WS 4, PS 0) @ 0xBC13
[ 9455.340489] [drm:atom_execute_table_locked] *ERROR* atombios stuck executing BAAC (len 76, WS 0, PS 8) @ 0xBAB4
[ 9455.568120] radeon 0000:01:00.0: Wait for MC idle timedout !
[ 9455.795784] radeon 0000:01:00.0: Wait for MC idle timedout !
[ 9455.820793] [drm] PCIE GART of 512M enabled (table at 0x0000000000040000).
[ 9455.821119] radeon 0000:01:00.0: WB enabled
[ 9456.065584] [drm:r600_ring_test] *ERROR* radeon: ring test failed (scratch(0x8504)=0xFFFFFFFF)
[ 9456.065591] [drm:evergreen_resume] *ERROR* evergreen startup failed on resume
[ 9461.061054] [drm:atom_op_jump] *ERROR* atombios stuck in loop for more than 5secs aborting
[ 9461.061074] [drm:atom_execute_table_locked] *ERROR* atombios stuck executing CDDC (len 62, WS 0, PS 0) @ 0xCDF8
[ 9466.058587] [drm:atom_op_jump] *ERROR* atombios stuck in loop for more than 5secs aborting
[ 9466.058604] [drm:atom_execute_table_locked] *ERROR* atombios stuck executing CDDC (len 62, WS 0, PS 0) @ 0xCDF8
[ 9471.056127] [drm:atom_op_jump] *ERROR* atombios stuck in loop for more than 5secs aborting
[ 9471.056143] [drm:atom_execute_table_locked] *ERROR* atombios stuck executing CDDC (len 62, WS 0, PS 0) @ 0xCDF8
[ 9476.053651] [drm:atom_op_jump] *ERROR* atombios stuck in loop for more than 5secs aborting
[ 9476.053668] [drm:atom_execute_table_locked] *ERROR* atombios stuck executing CDDC (len 62, WS 0, PS 0) @ 0xCDF8

Anyway, eventually the command finishes and I can run:

sudo bash -c "echo OFF > /sys/kernel/debug/vgaswitcheroo/switch"

No error now, and the power consumption goes down to the expected level.

Details that may be useful:
Linux version 3.2.0-26-generic (buildd@batsu) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #41-Ubuntu SMP Thu Jun 14 17:49:24 UTC 2012

/proc/cpuinfo (repeated 4 times)
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 42
model name	: Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
stepping	: 7
microcode	: 0x14
cpu MHz		: 800.000
cache size	: 3072 KB
physical id	: 0
siblings	: 4
core id		: 0
cpu cores	: 2
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm ida arat epb xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid
bogomips	: 4988.75
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

/proc/modules:
kvm_intel 137721 0 - Live 0x0000000000000000
kvm 415549 1 kvm_intel, Live 0x0000000000000000
parport_pc 32866 0 - Live 0x0000000000000000
ppdev 17113 0 - Live 0x0000000000000000
rfcomm 47604 14 - Live 0x0000000000000000
bnep 18281 2 - Live 0x0000000000000000
binfmt_misc 17540 1 - Live 0x0000000000000000
snd_hda_codec_hdmi 32474 1 - Live 0x0000000000000000
snd_hda_codec_realtek 223867 1 - Live 0x0000000000000000
arc4 12529 2 - Live 0x0000000000000000
uvcvideo 72627 0 - Live 0x0000000000000000
videodev 98259 1 uvcvideo, Live 0x0000000000000000
v4l2_compat_ioctl32 17128 1 videodev, Live 0x0000000000000000
psmouse 87692 0 - Live 0x0000000000000000
serio_raw 13211 0 - Live 0x0000000000000000
sony_laptop 45393 0 - Live 0x0000000000000000
mac_hid 13253 0 - Live 0x0000000000000000
btusb 18288 2 - Live 0x0000000000000000
bluetooth 180104 23 rfcomm,bnep,btusb, Live 0x0000000000000000
snd_hda_intel 33773 5 - Live 0x0000000000000000
snd_hda_codec 127706 3 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel, Live 0x0000000000000000
snd_hwdep 13668 1 snd_hda_codec, Live 0x0000000000000000
snd_pcm 97188 4 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec, Live 0x0000000000000000
snd_seq_midi 13324 0 - Live 0x0000000000000000
snd_rawmidi 30748 1 snd_seq_midi, Live 0x0000000000000000
snd_seq_midi_event 14899 1 snd_seq_midi, Live 0x0000000000000000
snd_seq 61896 2 snd_seq_midi,snd_seq_midi_event, Live 0x0000000000000000
snd_timer 29990 2 snd_pcm,snd_seq, Live 0x0000000000000000
snd_seq_device 14540 3 snd_seq_midi,snd_rawmidi,snd_seq, Live 0x0000000000000000
i915 468737 3 - Live 0x0000000000000000
iwlwifi 332672 0 - Live 0x0000000000000000
video 19596 1 i915, Live 0x0000000000000000
mac80211 506816 1 iwlwifi, Live 0x0000000000000000
mei 41616 0 - Live 0x0000000000000000 (C)
radeon 804372 0 - Live 0x0000000000000000
cfg80211 205544 2 iwlwifi,mac80211, Live 0x0000000000000000
ttm 76949 1 radeon, Live 0x0000000000000000
rts_pstor 445196 0 - Live 0x0000000000000000 (C)
drm_kms_helper 46978 2 i915,radeon, Live 0x0000000000000000
snd 78855 19 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_rawmidi,snd_seq,snd_timer,snd_seq_device, Live 0x0000000000000000
drm 242038 6 i915,radeon,ttm,drm_kms_helper, Live 0x0000000000000000
soundcore 15091 1 snd, Live 0x0000000000000000
snd_page_alloc 18529 2 snd_hda_intel,snd_pcm, Live 0x0000000000000000
i2c_algo_bit 13423 2 i915,radeon, Live 0x0000000000000000
lp 17799 0 - Live 0x0000000000000000
parport 46562 3 parport_pc,ppdev,lp, Live 0x0000000000000000
r8169 62099 0 - Live 0x0000000000000000

/proc/ioports:
0000-0cf7 : PCI Bus 0000:00
  0000-001f : dma1
  0020-0021 : pic1
  0040-0043 : timer0
  0050-0053 : timer1
  0060-0060 : keyboard
  0062-0062 : EC data
  0064-0064 : keyboard
  0066-0066 : EC cmd
  0070-0077 : rtc0
  0080-008f : dma page reg
  00a0-00a1 : pic2
  00c0-00df : dma2
  00f0-00ff : fpu
  0400-0453 : pnp 00:05
    0400-0403 : ACPI PM1a_EVT_BLK
    0404-0405 : ACPI PM1a_CNT_BLK
    0408-040b : ACPI PM_TMR
    0410-0415 : ACPI CPU throttle
    0420-042f : ACPI GPE0_BLK
    0450-0450 : ACPI PM2_CNT_BLK
  0454-0457 : pnp 00:07
  0458-047f : pnp 00:05
  0500-057f : pnp 00:05
  0680-069f : pnp 00:05
0cf8-0cff : PCI conf1
0d00-ffff : PCI Bus 0000:00
  1000-100f : pnp 00:05
  164e-164f : pnp 00:05
  2000-2000 : pnp 00:05
  2004-2004 : pnp 00:05
  3000-3fff : PCI Bus 0000:05
    3000-30ff : 0000:05:00.0
      3000-30ff : r8169
  4000-4fff : PCI Bus 0000:04
  5000-5fff : PCI Bus 0000:03
  6000-6fff : PCI Bus 0000:02
  7000-7fff : PCI Bus 0000:01
    7000-70ff : 0000:01:00.0
  8000-803f : 0000:00:02.0
  8040-805f : 0000:00:1f.3
  8060-807f : 0000:00:1f.2
    8060-807f : ahci
  8090-8097 : 0000:00:1f.2
    8090-8097 : ahci
  8098-809f : 0000:00:1f.2
    8098-809f : ahci
  80b8-80bb : 0000:00:1f.2
    80b8-80bb : ahci
  80bc-80bf : 0000:00:1f.2
    80bc-80bf : ahci
  ffff-ffff : pnp 00:05
    ffff-ffff : pnp 00:05

/proc/iomem:
00000000-0000ffff : reserved
00010000-0009d7ff : System RAM
0009d800-0009ffff : reserved
000a0000-000bffff : PCI Bus 0000:00
000c0000-000cffff : Video ROM
000e0000-000fffff : reserved
  000f0000-000fffff : System ROM
00100000-9ae3efff : System RAM
  01000000-01666eeb : Kernel code
  01666eec-01ce42ff : Kernel data
  01dd3000-01f28fff : Kernel bss
9ae3f000-9aebefff : reserved
9aebf000-9afbefff : ACPI Non-volatile Storage
9afbf000-9affefff : ACPI Tables
9afff000-9affffff : System RAM
9b000000-9f9fffff : reserved
9fa00000-feafffff : PCI Bus 0000:00
  9fa00000-9fa00fff : pnp 00:0a
  a0000000-afffffff : PCI Bus 0000:01
    a0000000-afffffff : 0000:01:00.0
  b0000000-bfffffff : 0000:00:02.0
  c0000000-c03fffff : 0000:00:02.0
  c0400000-c13fffff : PCI Bus 0000:02
  c1400000-c23fffff : PCI Bus 0000:03
  c2400000-c33fffff : PCI Bus 0000:04
  c3400000-c43fffff : PCI Bus 0000:05
    c3400000-c3403fff : 0000:05:00.0
      c3400000-c3403fff : r8169
    c3404000-c3404fff : 0000:05:00.0
      c3404000-c3404fff : r8169
  c4400000-c53fffff : PCI Bus 0000:05
  c5400000-c63fffff : PCI Bus 0000:04
    c5400000-c5401fff : 0000:04:00.0
      c5400000-c5401fff : xhci_hcd
  c6400000-c73fffff : PCI Bus 0000:03
    c6400000-c6400fff : 0000:03:00.0
      c6400000-c6400fff : rts_pstor
  c7400000-c83fffff : PCI Bus 0000:02
    c7400000-c7401fff : 0000:02:00.0
      c7400000-c7401fff : iwlwifi
  c8400000-c93fffff : PCI Bus 0000:01
    c8400000-c841ffff : 0000:01:00.0
    c8420000-c843ffff : 0000:01:00.0
  c9400000-c9403fff : 0000:00:1b.0
    c9400000-c9403fff : ICH HD audio
  c9404000-c940400f : 0000:00:16.0
    c9404000-c940400f : mei
  c9406000-c94060ff : 0000:00:1f.3
  c9408000-c94087ff : 0000:00:1f.2
    c9408000-c94087ff : ahci
  c9409000-c94093ff : 0000:00:1d.0
    c9409000-c94093ff : ehci_hcd
  c940a000-c940a3ff : 0000:00:1a.0
    c940a000-c940a3ff : ehci_hcd
  e0000000-efffffff : PCI MMCONFIG 0000 [bus 00-ff]
    e0000000-efffffff : reserved
      e0000000-efffffff : pnp 00:0a
feb00000-feb03fff : reserved
fec00000-fec00fff : reserved
  fec00000-fec003ff : IOAPIC 0
fed00000-fed003ff : HPET 0
fed10000-fed19fff : reserved
  fed10000-fed17fff : pnp 00:0a
  fed18000-fed18fff : pnp 00:0a
  fed19000-fed19fff : pnp 00:0a
fed1c000-fed1ffff : reserved
  fed1c000-fed1ffff : pnp 00:0a
fed20000-fed3ffff : pnp 00:0a
fed90000-fed93fff : pnp 00:0a
fee00000-fee00fff : Local APIC
  fee00000-fee00fff : reserved
ffd80000-ffffffff : reserved
100000000-1dfdfffff : System RAM
1dfe00000-1dfffffff : RAM buffer
Comment 1 Peter Wu 2012-10-05 15:01:01 UTC
Possibly a duplicate of https://bugzilla.kernel.org/show_bug.cgi?id=44391 (which is about Nvidia Optimus, but a solution possibly has the same patch)

So you have a MUX-less hybrid Intel / AMD setup if I am not mistaken?
Comment 2 Alessandro Pignotti 2012-10-05 17:56:21 UTC
Yes my setup is as you described. The bug looks the same as this indeed https://bugzilla.kernel.org/show_bug.cgi?id=44391
Comment 3 Peter Wu 2012-10-05 19:13:52 UTC
You can mark this bug as a duplicate of that bug.

Does your machine have an indicator that shows whether the discrete graphics card is enabled or not? If you happens to have such an indicator and also have a Windows installation with drivers installed, can you check what happens around suspend/resume?

On my Nvidia Optimus laptop, the following holds for a s/r cycle under Windows:

- indicator shows initially that the dGPU is deactivated.
- Before suspend, indicator shows that dGPU is activated.
- On resume, the indicator initially shows the dGPU as deactivated. Then, it turns shortly to "activated", and then to "deactivated" again.
- indicator finally shows the dGPU as deactivated.

Is this also true for AMD?
Comment 4 Alessandro Pignotti 2012-10-05 19:22:05 UTC
Unfortunately I don't have such indicator. The windows way of solving the issue is using a physical switch.

*** This bug has been marked as a duplicate of bug 44391 ***
Comment 5 Peter Wu 2012-10-05 19:25:38 UTC
Is that a switch (left/right slide) or toggle (slide to one side and it goes back automatically)?
Comment 6 Alessandro Pignotti 2012-10-05 19:36:03 UTC
It's a switch. On linux I think it justs send a generic input event. So it's implemented in software under windows.
Comment 7 Peter Wu 2012-10-05 20:00:56 UTC
Thank you for letting me know. My VGA button (for switching between performance and powersave mode) is also implemented as a software solution. When pressed, a WMI ACPI event is generated which is processed by the Hotkey.exe program in Windows. I guess yours works in a similar way.

Btw, are you able to test the aforementioned suspend/resume cycle in windows?