Bug 81382 - Text console blanking does not go away
Summary: Text console blanking does not go away
Status: RESOLVED FIXED
Alias: None
Product: DRI
Classification: Unclassified
Component: DRM/Radeon (show other bugs)
Version: XOrg git
Hardware: Other All
: medium normal
Assignee: Default DRI bug account
QA Contact:
URL:
Whiteboard:
Keywords:
: 70207 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-07-15 11:25 UTC by Denys Vlasenko
Modified: 2016-08-15 13:40 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
dmesg (85.42 KB, text/plain)
2014-07-15 11:25 UTC, Denys Vlasenko
no flags Details
Debugging messages patch (23.66 KB, patch)
2014-07-15 12:29 UTC, Denys Vlasenko
no flags Details | Splinter Review
set the default backlight level to something reasonable (1.81 KB, patch)
2014-07-15 13:55 UTC, Alex Deucher
no flags Details | Splinter Review
lspci output for amilo (2.14 KB, text/plain)
2014-09-16 07:00 UTC, Patrick
no flags Details
vbios from Amilo (61.00 KB, application/octet-stream)
2014-09-16 07:01 UTC, Patrick
no flags Details
lspci -vnn for Amilo (840 bytes, text/plain)
2014-09-17 07:07 UTC, Patrick
no flags Details
patch 1/2 (4.05 KB, patch)
2014-09-17 15:38 UTC, Alex Deucher
no flags Details | Splinter Review
patch 2/2 (1.25 KB, patch)
2014-09-17 15:39 UTC, Alex Deucher
no flags Details | Splinter Review
lspci -vnn for Daniel's amilo (841 bytes, text/plain)
2014-09-19 15:40 UTC, Daniel Kirsten
no flags Details
lspci -vnn for Christophe's iMac (9.18 KB, text/plain)
2015-04-21 20:11 UTC, Christophe Migliorini
no flags Details

Description Denys Vlasenko 2014-07-15 11:25:08 UTC
Created attachment 102847 [details]
dmesg

I log in as root on a text virtual console.
After about 10 minutes screen blanks.

Surprisingly, pressing a key does *not* unblank the screen!

Machine is still alive (I can ssh into it), and typed keys even reach the console: I can type e.g. "ls -lR /usr" and I see disk indicator blinking, ls process is visible in the ps in ssh session, etc.

This does not happen in X.

This is observed on Lenovo T60, on RHEL7 kernel and also on recent upstream kernel 3.15.5.

Investigation had revealed that VT unblanking code, after all the hard work it done to turn display back on, calls ATOM_LCD_BLOFF (backlight off, numeric value 2) function.

Digging further, I discovered that fb_blank(blank=0) almost at its end calls fb_notifier_call_chain(FB_EVENT_BLANK). Which calls backlight.c::fb_notifier_callback(), which tries to set brightness via radeon_atom_backlight_update_status(), which does
atombios_set_backlight_level(radeon_atom_bl_level()), but radeon_atom_bl_level() is zero (it's an uint8_t, brightness level). So it's essentially atombios_set_backlight_level(0) and it switches backlight off.

In drivers/gpu/drm/radeon/*, bd->props.brightness, surprisingly, is only set in radeon_atom_backlight_init() and radeon_legacy_backlight_init(), all other locations are only reading it. So, if this init code sets it to 0, then VT unblanking code will use this zero value as brightness to restore, causing this bug.

And indeed, that's what happens on the machine exhibiting this bug:

[    2.301563] radeon_atom_get_backlight_level_from_reg: RADEON_BIOS_2_SCRATCH
[    2.301633] radeon_atom_get_backlight_level_from_reg: bios_2_scratch:00000000
[    2.301704] radeon_atom_backlight_init: bd->props.brightness=0
[    2.301780] radeon_atom_backlight_update_status: atombios_set_back

The full dmesg of the RHEL7 boot with many debug printks added is attached. (Sorry, I started debugging it on RHEL7, I believe mainline does not differ significantly).
It shows the following: After "setterm -blank 1 && sleep 60", VT blanking triggers at ~362 seconds, and at ~370 seconds VT is trying to unblank because of keyboard activity. The bug is evident here:

[  370.852058] fb_blank: fb_notifier_call_chain(FB_EVENT_BLANK)...
[  370.852061] fbcon_event_notify: case FB_EVENT_BLANK: fbcon_fb_blanked(blank:0)
[  370.852063] fbcon_fb_blanked: do_unblank_screen(0)
[  370.852064] do_unblank_screen: entered on cpu 0
[  370.852066] do_unblank_screen: !console_blanked on cpu 0
[  370.852068] backlight: drivers/video/backlight/backlight.c:fb_notifier_callback: backlight_update_status()
[  370.852071] radeon_atom_backlight_update_status: atombios_set_backlight_level()
[  370.852072] radeon_atom_bl_level: level = bd->props.brightness:0
[  370.852074] atombios_set_backlight_level(level:0)
[  370.852077] atombios_set_backlight_level: atom_execute_table(ATOM_LCD_BLOFF)
^^^^^^^^^^^^^^^^^^^^ THIS TURNS OFF DISPLAY ^^^^^^^^^^^^^^^^^
[  370.852083] atom_execute_table_locked(index:23,*params:ffff8802) returns 0
[  370.852085] backlight: drivers/video/backlight/backlight.c:fb_notifier_callback: backlight_update_status()
[  370.852940] fb_blank returns 0
[  370.852942] fbcon_blank: update_screen()...
[  370.862313] do_unblank_screen: done on cpu 0

Note: PCI error seen during blanking is not causing this bug. It happens on first blanking (including Xserver screen blankings, which do not exhibit this bug), and never repeats. Google says it's a known issue on Radeon, comes from PCIe lanes reconfiguration.

I am unsure how to proceed from here. Maybe init code needs fixing to properly read backlight brightness on this hardware? I think radeon people are more qualified to take it from here. I'm willing to test patches.
Comment 1 Denys Vlasenko 2014-07-15 12:29:47 UTC
Created attachment 102852 [details] [review]
Debugging messages patch
Comment 2 Alex Deucher 2014-07-15 13:37:37 UTC
*** Bug 70207 has been marked as a duplicate of this bug. ***
Comment 3 Alex Deucher 2014-07-15 13:55:27 UTC
Created attachment 102856 [details] [review]
set the default backlight level to something reasonable

Does this patch help?
Comment 4 Denys Vlasenko 2014-07-15 14:24:44 UTC
(In reply to comment #3)
> Created attachment 102856 [details] [review] [review]
> set the default backlight level to something reasonable
> 
> Does this patch help?

Yes, it does.

Maybe add a comment there why this check is necessary?
Comment 5 Alex Deucher 2014-07-15 14:33:23 UTC
Will do.
Comment 6 David Heidelberg (okias) 2014-07-16 18:26:11 UTC
Work perfectly on Toshiba A210-15j!


Tested-by: David Heidelberger <david.heidelberger@ixit.cz>
Comment 7 David Heidelberg (okias) 2014-09-05 20:58:58 UTC
Ok, this fix work, but cause another problem (tested with 3.15.5+patch and 3.16.1).

When display goes off, backlight goes off.
When display goes on, backlight is set to MAX.
When display goes off again, backligh remains MAX.
After pressing key, LCD works, backlight stay at MAX level.
When display goes off, backlight is still MAX.
Comment 8 Daniel Kirsten 2014-09-10 20:34:05 UTC
The above patch causes a problem on my Amilo Xi 2550 (RadeonHD 2600).

The behaviour for kernel-3.14.8-100.fc19 (without patch):

The value of /sys/class/backlight/radeon_bl0/brightness is 0. 
Whenever I write something (0-255) to  /sys/class/backlight/radeon_bl0/brightness, 
the backlight is turned off, and I am not able to turn on the backlight again. 
However, I can still shutdown the system (Ctr+Alt+Fx, login as root, and give a 
shutdown command.

I can control the backlight by writing values 0-7 to /sys/class/backlight/acpi_video0/brightness.

The behaviour for kernel-3.14.17-100.fc19 (with patch):

The backlight is turned off during the boot up process, when the kernel switches into 
graphics mode.    
I commented out the lines 233-234 in drivers/gpu/drm/radeon/atombios_encoders.c, 
and then, the problem disappeared, i.e., the backlight stays on when the kernel switches 
into graphics mode.

Best regards,
Daniel
Comment 9 Denys Vlasenko 2014-09-11 10:42:35 UTC
(In reply to comment #7)
> Ok, this fix work, but cause another problem (tested with 3.15.5+patch and
> 3.16.1).
> 
> When display goes off, backlight goes off.
> When display goes on, backlight is set to MAX.
> When display goes off again, backligh remains MAX.
> After pressing key, LCD works, backlight stay at MAX level.
> When display goes off, backlight is still MAX.

I would say it means that merely treating backlight value of 0 as MAX is not the best idea.

Maybe we need an additional bool variable "failed to read initial BL value, don't ever try to set it", set it if initial read of BL value is 0, and if it is set, never try to change BL level?
Comment 10 Alex Deucher 2014-09-11 13:58:49 UTC
(In reply to comment #7)
> Ok, this fix work, but cause another problem (tested with 3.15.5+patch and
> 3.16.1).
> 
> When display goes off, backlight goes off.
> When display goes on, backlight is set to MAX.
> When display goes off again, backligh remains MAX.
> After pressing key, LCD works, backlight stay at MAX level.
> When display goes off, backlight is still MAX.

Does the backlight respond correctly when adjusted via the sysfs blacklight interface?
Comment 11 Patrick 2014-09-12 22:40:45 UTC
I've got the same notebook as Daniel Kirsten, so I've searched for changes in the kernel code, which caused the dark screen. From that point, I've found the patch  from Alex Deucher and this bug report.

If I change /sys/class/backlight/radeon_bl0/brightness or /sys/class/backlight/acpi_video0 the display stayes dark.

@Alex
is this what you wanted to know? If not, please let me know, how I could help you to debug this problem!
Comment 12 Daniel Kirsten 2014-09-13 20:43:24 UTC
(In reply to comment #11)
> I've got the same notebook as Daniel Kirsten, 

They sold different Amilo Xi 2550, there are even some Amilo Xi 2550 with 
an Nvidia graphic card.

> If I change /sys/class/backlight/radeon_bl0/brightness or
> /sys/class/backlight/acpi_video0 the display stayes dark.

I can control brightness by writing 0-7 into 
/sys/class/backlight/acpi_video0/brightness

You should comment out lines 233-234 in drivers/gpu/drm/radeon/atombios_encoders.c,
i.e., 

/*  if (bd->props.brightness == 0)
    234                 bd->props.brightness = RADEON_MAX_BL_LEVEL;    */

then it works.

Daniel
Comment 13 Patrick 2014-09-15 20:41:54 UTC
(In reply to comment #12)

Hi Daniel,

correct, before that patch, the display was controllable through /sys/class/backlight/acpi_video0/brightness.

After that patch, the display is always dark.

The only change which was done by Alex, was adding the lines, which you commeted out. (If I understood the code correct, the other two lines, which were removed, are obsolete and not needed).

So if you removed that two lines, then you've got the same code as before and our Amilo (with ATI card) is working fine, but Denys problem will appear again...
Comment 14 Alex Deucher 2014-09-15 20:47:50 UTC
(In reply to comment #11)
> If I change /sys/class/backlight/radeon_bl0/brightness or
> /sys/class/backlight/acpi_video0 the display stayes dark.
> 
> @Alex
> is this what you wanted to know? If not, please let me know, how I could
> help you to debug this problem!

Without the patch from this bug report applied (e.g., when your display is working), which, if any, of the blacklight interfaces work?  It seems like perhaps your laptop claims to have a GPU controlled backlight, but really uses an external backlight control.  Can you attach a copy of your vbios?  TO get a copy of your vbios:

(as root)
(use lspci to get the bus id)
cd /sys/bus/pci/devices/<pci bus id>
echo 1 > rom
cat rom > /tmp/vbios.rom
echo 0 > rom
Comment 15 Patrick 2014-09-16 07:00:00 UTC
Created attachment 106353 [details]
lspci output for amilo
Comment 16 Patrick 2014-09-16 07:01:41 UTC
Created attachment 106354 [details]
vbios from Amilo
Comment 17 Patrick 2014-09-16 07:17:24 UTC
(In reply to comment #14)

This could be true. I can control it via /sys/class/backlight/acpi_video0/brightness. If I change /sys/class/backlight/radeon_bl0/brightness then the display is nearly black and cannot be restored.

After reboot the following values are set:
acpi_video0 = 7
radeon_bl0 = 0

I've attached a lspci -vvv to " lspci output for amilo" and the vbios to "vbios from Amilo"
Comment 18 Alex Deucher 2014-09-17 01:04:59 UTC
Can you attach the lspci -vnn output for your GPU?
Comment 19 Patrick 2014-09-17 07:07:13 UTC
Created attachment 106410 [details]
lspci -vnn for Amilo

sure, here it is
Comment 20 Alex Deucher 2014-09-17 15:38:50 UTC
Created attachment 106441 [details] [review]
patch 1/2

Do the attached patches help?  The first patch adds a backlight module parameter to disable the gpu backlight device for testing.  The second adds a quirk for the Amilo laptop.
Comment 21 Alex Deucher 2014-09-17 15:39:17 UTC
Created attachment 106442 [details] [review]
patch 2/2
Comment 22 Patrick 2014-09-17 16:42:07 UTC
Thanks for the patch, but I'm on vacation till 26th September, so long I cannot test it.

@Daniel
As you've got the same problem, could you test the patches?
Comment 23 Daniel Kirsten 2014-09-18 07:54:57 UTC
I can test the patches from 2014-09-17 on my amilo.

Can I apply them to the current fedora kernel code 3.14.18-100?

Should I apply both patches or test each patch separately?

Daniel
Comment 24 Alex Deucher 2014-09-18 13:09:02 UTC
Apply them both together.
Comment 25 Alex Deucher 2014-09-18 13:10:28 UTC
(In reply to comment #24)
> Apply them both together.

Well, assuming your laptop has the same pci ids as Patrick.  If not, just append radeon.backlight=0 to the kernel command line in grub and attach your lspci -vnn output.
Comment 26 Daniel Kirsten 2014-09-18 19:27:12 UTC
(In reply to comment #25)

The pci-id of the VGA Controller is 01:00.0 for my Amilo.

However, I cannot apply the patches to the 3.14.18-100.fc19 kernel:

patch --dry-run -p1 < ~/software/0001-drm-radeon-add-a-module-parameter-for-backlight-cont.patch
checking file drivers/gpu/drm/radeon/radeon.h
Hunk #1 FAILED at 106.
1 out of 1 hunk FAILED
checking file drivers/gpu/drm/radeon/radeon_drv.c
Hunk #1 FAILED at 181.
Hunk #2 succeeded at 237 with fuzz 2 (offset -26 lines).
1 out of 2 hunks FAILED
checking file drivers/gpu/drm/radeon/radeon_encoders.c
Exit 1


patch --dry-run -p1 < ~/software/0002-drm-radeon-add-a-backlight-quirk-for-Amilo-Xi-2550.patch
checking file drivers/gpu/drm/radeon/radeon_encoders.c
Hunk #1 FAILED at 173.
1 out of 1 hunk FAILED
Exit 1


Which kernel should I use to test the patches?

Daniel
Comment 27 Alex Deucher 2014-09-18 19:28:36 UTC
They are written against 3.17.
Comment 28 Alex Deucher 2014-09-19 13:14:21 UTC
(In reply to comment #26)
> (In reply to comment #25)
> 
> The pci-id of the VGA Controller is 01:00.0 for my Amilo.

That's the bus id.  I need the output of lspci -vnn
Comment 29 Daniel Kirsten 2014-09-19 15:38:49 UTC
I tested the patches from 2014-09-17 against 3.17-rc5.

When I applied both patches,  the backlight was not turned off, when the kernel switched into graphics mode. 
The kernel worked very well.

Without the patches, the backlight was turned off, when the kernel switched into graphics mode.

Daniel
Comment 30 Daniel Kirsten 2014-09-19 15:40:46 UTC
Created attachment 106554 [details]
lspci -vnn for Daniel's amilo
Comment 31 Alex Deucher 2014-09-19 16:20:53 UTC
(In reply to comment #30)
> Created attachment 106554 [details]
> lspci -vnn for Daniel's amilo

You have the same configuration as Patrick.

(In reply to comment #29)
> I tested the patches from 2014-09-17 against 3.17-rc5.
> 
> When I applied both patches,  the backlight was not turned off, when the
> kernel switched into graphics mode. 
> The kernel worked very well.

Great.  I'll make sure the patches get upstream.  Thanks for testing.
Comment 32 Patrick 2014-09-27 21:36:16 UTC
I've just tested the patches on my notebook, too. Also here, the problem is fixed, with the patches you provided.

Do you already know, in which upstream versions, the fix will be published? 3.17? Or in an 3.16.x already?
Comment 34 Christophe Migliorini 2015-04-21 20:05:52 UTC
Hi, it took me quite some time to get here, but hopefully you can still solve my problem.
I'm running a 2006 Intel iMac (Core Duo) under Unbuntu 12.04LTS server, which sits on my desk and almost never log to the console, which would normally go blank a few minutes after boot.

There is strong evidence that this patch found its way to my "stock" kernel back in september 2014, and since then my iMac exhibits the following behaviour after boot:
- whenever the console blanking activates, backlight goes to MAX (with my LCD screen going all strange and overheating — even causing fans to blow)
- only way out is to echo 0 > /sys/class/backlight/radeon_bl0/brightness — which I 'crontabbed' but is not exactly satisfactory.
- any other value causes the backlight to go all the way up and overheat.

I did try to "echo 1 > /sys/class/backlight/acpi_video0/brightness" today, and that caused the iMac to reboot.

I have not experimented anything else, but would be happy to help.

uname is "Linux xxx 3.13.0-49-generic #81~precise1-Ubuntu SMP Wed Mar 25 16:32:40 UTC 2015 i686 i686 i386 GNU/Linux"
Comment 35 Christophe Migliorini 2015-04-21 20:11:03 UTC
Created attachment 115253 [details]
lspci -vnn for Christophe's iMac
Comment 37 Christophe Migliorini 2015-04-22 09:32:54 UTC
Apparently only "set the default backlight level to something reasonable" patch was applied to 3.13, so I don't have the "radeon_encoder_add_backlight" function, thus this won't work at all.

Would you suggest I first apply the patch published here on 2014-09-17?
Comment 38 Christophe Migliorini 2015-04-23 06:02:03 UTC
Well, I did, '2014-09-17 15:38 UTC' and '2014-09-17 15:39 UTC' patches apply ok and it works.  Sorry for the inconvenience.
(perhaps one should consider pushing these two upstream instead of the fist one?)...
Comment 39 Alex Deucher 2015-04-23 14:12:37 UTC
(In reply to Christophe Migliorini from comment #38)
> Well, I did, '2014-09-17 15:38 UTC' and '2014-09-17 15:39 UTC' patches apply
> ok and it works.  Sorry for the inconvenience.
> (perhaps one should consider pushing these two upstream instead of the fist
> one?)...

Those patches are upstream as well.
Comment 40 Alex Deucher 2015-04-23 14:15:11 UTC
(In reply to Alex Deucher from comment #39)
> (In reply to Christophe Migliorini from comment #38)
> > Well, I did, '2014-09-17 15:38 UTC' and '2014-09-17 15:39 UTC' patches apply
> > ok and it works.  Sorry for the inconvenience.
> > (perhaps one should consider pushing these two upstream instead of the fist
> > one?)...
> 
> Those patches are upstream as well.

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=bc13018b5eba26ca229b33763c9e61fac31a1925
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=8aff6ad5a393b8e2ad00dce4d278ecf41397bf0d
Comment 41 Christophe Migliorini 2015-04-24 13:59:32 UTC
Good. Hopefully into 12.04LTS before it's no longer supported :-).
Comment 42 David Heidelberg (okias) 2016-08-13 12:01:02 UTC
Maybe this bug can be closed?


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.