Bug 70651 - cannot write to power_dpm_force_performance_level: invalid argument (radeon 7730m)
Summary: cannot write to power_dpm_force_performance_level: invalid argument (radeon 7...
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Video(DRI - non Intel) (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: drivers_video-dri
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-16 00:25 UTC by Fabio Sangiovanni
Modified: 2014-09-29 18:34 UTC (History)
2 users (show)

See Also:
Kernel Version: 3.13.3
Subsystem:
Regression: No
Bisected commit-id:


Attachments
3.13.3 dmesg (73.30 KB, text/plain)
2014-02-16 00:25 UTC, Fabio Sangiovanni
Details
possible fix for SI (3.94 KB, patch)
2014-02-21 15:49 UTC, Alex Deucher
Details | Diff
patched_radeon_pm.c (48.11 KB, text/x-csrc)
2014-02-25 20:24 UTC, Fabio Sangiovanni
Details

Description Fabio Sangiovanni 2014-02-16 00:25:22 UTC
Created attachment 126301 [details]
3.13.3 dmesg

hi,

I'm using a notebook with intel ivy bridge + amd radeon 7730m hybrid graphics.
With the latest stable kernel (3.13.3) I can't echo (low, high, auto) to /sys/class/drm/card0/device/power_dpm_force_performance_level:

root@darkstar:~# echo "high"> /sys/class/drm/card0/device/power_dpm_force_performance_level
-bash: echo: write error: Invalid argument
root@darkstar:~# echo "low" /sys/class/drm/card0/device/power_dpm_force_performance_level 
low /sys/class/drm/card0/device/power_dpm_force_performance_level
root@darkstar:~# echo "auto" /sys/class/drm/card0/device/power_dpm_force_performance_level 
auto /sys/class/drm/card0/device/power_dpm_force_performance_level

I cannot say it's a regression since I haven't tried previous kernels.
I can echo "battery", "performance" or "balanced" to /sys/class/drm/card0/device/power_dpm_state


Some other info:

root@darkstar:~# cat /sys/class/drm/card0/device/power_dpm_force_performance_level
auto

root@darkstar:~# lspci|grep VGA
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
01:00.0 VGA compatible controller: AMD/ATI [Advanced Micro Devices, Inc.] Chelsea LP [Radeon HD 7730M] (rev ff)

root@darkstar:~# cat /sys/kernel/debug/vgaswitcheroo/switch 
0:DIS: :DynOff:0000:01:00.0
1:IGD:+:Pwr:0000:00:02.0

root@darkstar:~# for i in /sys/class/drm/card0/device/power/*; do echo "$i: $(cat $i)"; done
/sys/class/drm/card0/device/power/autosuspend_delay_ms: 5000
/sys/class/drm/card0/device/power/control: auto
/sys/class/drm/card0/device/power/runtime_active_time: 33415
/sys/class/drm/card0/device/power/runtime_status: suspended
/sys/class/drm/card0/device/power/runtime_suspended_time: 934700
/sys/class/drm/card0/device/power/wakeup: disabled
/sys/class/drm/card0/device/power/wakeup_abort_count: 
/sys/class/drm/card0/device/power/wakeup_active: 
/sys/class/drm/card0/device/power/wakeup_active_count: 
/sys/class/drm/card0/device/power/wakeup_count: 
/sys/class/drm/card0/device/power/wakeup_expire_count: 
/sys/class/drm/card0/device/power/wakeup_last_time_ms: 
/sys/class/drm/card0/device/power/wakeup_max_time_ms: 
/sys/class/drm/card0/device/power/wakeup_total_time_ms:

root@darkstar:~# cat /sys/kernel/debug/dri/0/radeon_pm_info 
default engine clock: 575000 kHz
current engine clock: 210280 kHz
default memory clock: 900000 kHz
current memory clock: 00 kHz
voltage: 825 mV
PCIE lanes: 16

(This last output is different from the ones I've seen around)

Am I missing something?
dmesg attached
Thanks
Comment 1 Fabio Sangiovanni 2014-02-16 10:23:17 UTC
Sorry, there was obviously an error in the echo commands reported in the previous comment.

Actual relevant result is:

root@darkstar:~# echo "high"> /sys/class/drm/card0/device/power_dpm_force_performance_level
-bash: echo: write error: Invalid argument

root@darkstar:~# echo "low"> /sys/class/drm/card0/device/power_dpm_force_performance_level
-bash: echo: write error: Invalid argument

root@darkstar:~# echo "auto"> /sys/class/drm/card0/device/power_dpm_force_performance_level
-bash: echo: write error: Invalid argument
Comment 2 Fabio Sangiovanni 2014-02-21 14:34:37 UTC
hi, any advice on this, please?
Comment 3 Alex Deucher 2014-02-21 15:15:24 UTC
Does it work properly if you disable runtime pm?  Boot with radeon.runpm=0 on the kernel command line in grub.
Comment 4 Alex Deucher 2014-02-21 15:49:46 UTC
Created attachment 126951 [details]
possible fix for SI

Starting with 3.13, the driver automatically powers down the dGPU on hybrid laptops when it's not in use.  Accessing the sysfs and debufgs information when it's powered down is invalid since the gpu is powered down.  This patch returns sensible values when you try to get/set this information when the GPU is powered off.
Comment 5 Fabio Sangiovanni 2014-02-23 22:36:18 UTC
hi, I'm sorry but the patch doesn't seem to work to me.
I've applied it to 3.13.3:


root@darkstar:/usr/src/linux# patch -p1 < patch.txt 
patching file drivers/gpu/drm/radeon/radeon_pm.c
Hunk #7 succeeded at 1580 (offset -20 lines).


This is what I get:

root@darkstar:~# cat /sys/kernel/debug/vgaswitcheroo/switch 
0:DIS: :DynOff:0000:01:00.0
1:IGD:+:Pwr:0000:00:02.0

root@darkstar:~# cat /sys/class/drm/card0/device/power_dpm_state 
balanced

root@darkstar:~# cat /sys/class/drm/card0/device/power_dpm_force_performance_level 
auto

root@darkstar:~# echo 'high' > /sys/class/drm/card0/device/power_dpm_force_performance_level 
-bash: echo: write error: Invalid argument
root@darkstar:~# echo 'low' > /sys/class/drm/card0/device/power_dpm_force_performance_level 
-bash: echo: write error: Invalid argument
root@darkstar:~# echo 'auto' > /sys/class/drm/card0/device/power_dpm_force_performance_level 
-bash: echo: write error: Invalid argument

root@darkstar:~# cat /sys/kernel/debug/dri/0/radeon_pm_info 
default engine clock: 575000 kHz
current engine clock: 210280 kHz
default memory clock: 900000 kHz
current memory clock: 00 kHz
voltage: 825 mV
PCIE lanes: 16


Plus, I've noticed this (unsure if it's missing some sort of parsing):
root@darkstar:~# echo 'batteryxxxx' > /sys/class/drm/card0/device/power_dpm_state 
root@darkstar:~# cat /sys/class/drm/card0/device/power_dpm_state
battery

(Same result with 'performancexxxx' and 'balancedxxxx')

It's ok with random letters as prefix:
root@darkstar:~# echo 'xxxxbattery' > /sys/class/drm/card0/device/power_dpm_state
-bash: echo: write error: Invalid argument

Please let me know if I can help somehow.

Thanks!
Comment 6 Fabio Sangiovanni 2014-02-24 13:29:05 UTC
Should I maybe apply the patch to a more recent version of the kernel, considering the offset of hunk #7?
Comment 7 Alex Deucher 2014-02-24 15:21:10 UTC
That patch is against 3.14rc; it should apply there.  The issue is that on hybrid laptops, the dGPU is powered down when not in use so you can't make adjustments to the dGPU when it's powered down.  It doesn't make sense to power it up to make the adjustments since it will just be powered down again right after.  As such the values you are reading back are garbage since the hw is powered down.  The patch just attempts to do something sensible when you try and access the hw via sysfs or debugfs and the dGPU is powered down.  You can disable the automatic dGPU power down by setting radeon.runpm=0 on the kernel command line in grub.
Comment 8 Fabio Sangiovanni 2014-02-24 15:26:30 UTC
Hi, thanks for the update.
In comment 5 I reported results with the patch applied to 3.13.3. Long story short: it behaves the same as with plain stock 3.13.3.
I'll try to apply the patch to the latest 3.14rc and report the results again.

Thanks!
Comment 9 Fabio Sangiovanni 2014-02-25 20:24:59 UTC
Created attachment 127471 [details]
patched_radeon_pm.c

Hi, I tried with 3.14-rc4, I still don't get the new sensible values upon accessing sysfs/debugfs when the asic is turned off.

With:

root@darkstar:~# cat /sys/kernel/debug/vgaswitcheroo/switch 
0:DIS: :DynOff:0000:01:00.0
1:IGD:+:Pwr:0000:00:02.0

I still get:

root@darkstar:~# cat /sys/kernel/debug/dri/64/radeon_pm_info 
default engine clock: 575000 kHz
current engine clock: 210280 kHz
default memory clock: 900000 kHz
current memory clock: 00 kHz
voltage: 825 mV
PCIE lanes: 16

Looking at the patch, I think I should get 'Chip powered off'.

Source of my drivers/gpu/drm/radeon/radeon_pm.c attached.
Comment 10 Fabio Sangiovanni 2014-02-28 09:03:32 UTC
Hi,

sorry, any news about this?
Is there something I can do to help?

radeon_pm_info still gives clocks and voltages to me, even if the dGPU is powered off (DynOff in vgaswitcheroo). I don't get 'Chip powered off'.

Am I missing something and everything is ok, or something's wrong with the patch? I'm willing to make tests on my hardware if it sounds useful, just let me know.

As stated in my previous comments, I tested 3.14rc4 + patch so far.
I attached the radeon_pm.c source file as it was when I compiled the kernel.

Thanks
Comment 11 Alex Deucher 2014-02-28 14:29:29 UTC
I haven't had time to look into why that patch is not working for you, but as I said previously, accessing the board via sysfs or debugfs while it's powered off produces invalid results so even when I fix the patch, the only change will be feedback from debugfs.  You can't actually change the power state of a powered off card.  I'll post an updated patch as soon as I figure out why it's not working.
Comment 12 Fabio Sangiovanni 2014-03-01 08:51:17 UTC
hi, thank you Alex.
To be clear, I absolutely didn't mean to rush you, just making myself available for testing and helping out as much as I can.

I understand the fact that it's not possible to access asic's parameters while it's turned off.

Thanks again for your work.
Comment 13 Zsolt Barat 2014-04-25 14:14:38 UTC
Hi,
thanks for your comment on this. I'm running into simmilar issue:

root@lisabook2:~# echo "low"> /sys/class/drm/card0/device/power_dpm_force_performance_level
-bash: echo: write error: Invalid argument

I'm also on a hybrid platform: MBP 8,2 with linux-3.14.0
I recently noticed this, that I can't set this value when I use the machine *without* an external Monitor which I usually don't.
Does it mean that the kernel now switches automatically to the non dGPU, when the dGPU is not in use? Would be great news.
Comment 14 Fabio Sangiovanni 2014-09-29 18:34:41 UTC
Everything is working fine as of 3.16.3, I think it's fine to close this bug.
Thanks!

Note You need to log in before you can comment on or make changes to this bug.