Bug 26942

Summary: radeon: screen distortion on resume
Product: Drivers Reporter: Brett Witherspoon (spoonb)
Component: Video(DRI - non Intel)Assignee: drivers_video-dri
Status: CLOSED CODE_FIX    
Severity: normal CC: alexdeucher, florian, kernelbug, maciej.rutecki, rjw
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.37 Tree: Mainline
Regression: Yes
Bug Depends on:    
Bug Blocks: 7216, 21782    
Attachments: Xorg.log
dmesg
vbios rom
dmesg after resume with DRM_INFO patch
avivotool regs all output for working and non working suspend
regs before resume
regs after resume
Both monitors
Single Monitor
fix bios scratch reg settings

Description Brett Witherspoon 2011-01-17 13:23:12 UTC
With v2.6.37, the radeon KMS drivers, and my RV730 I get a distorted screen when resuming from suspend to ram. This does not occur with v2.6.36 and I have bisected to this commit:

-----------------------------------------------------------------------------

From ba032a58d1f320039e7850fb6e8651695c1aa571 Mon Sep 17 00:00:00 2001
From: Alex Deucher <alexdeucher@gmail.com>
Date: Mon, 4 Oct 2010 17:13:01 -0400
Subject: [PATCH] drm/radeon/kms: rework spread spectrum handling

This patch reworks spread spectrum handling to enable it
properly on lvds and DP/eDP links.  It also fixes several
bugs in the old spread spectrum code.

-----------------------------------------------------------------------------

lspci -v

-----------------------------------------------------------------------------
03:00.0 VGA compatible controller: ATI Technologies Inc RV730 PRO [Radeon HD 4650] (prog-if 00 [VGA controller])
	Subsystem: PC Partner Limited Device 9498
	Flags: bus master, fast devsel, latency 0, IRQ 40
	Memory at e0000000 (64-bit, prefetchable) [size=256M]
	Memory at fb9e0000 (64-bit, non-prefetchable) [size=64K]
	I/O ports at ee00 [size=256]
	[virtual] Expansion ROM at fb900000 [disabled] [size=128K]
	Capabilities: [50] Power Management version 3
	Capabilities: [58] Express Legacy Endpoint, MSI 00
	Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+
	Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
	Kernel driver in use: radeon

03:00.1 Audio device: ATI Technologies Inc RV710/730
	Subsystem: PC Partner Limited R700 Audio Device [Radeon HD 4000 Series]
	Flags: bus master, fast devsel, latency 0, IRQ 44
	Memory at fb9fc000 (64-bit, non-prefetchable) [size=16K]
	Capabilities: [50] Power Management version 3
	Capabilities: [58] Express Legacy Endpoint, MSI 00
	Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+
	Capabilities: [100] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
	Kernel driver in use: HDA Intel
-----------------------------------------------------------------------------

Let me know what else I can provide.
Comment 1 Alex Deucher 2011-01-17 18:29:07 UTC
Please attach your xorg log, dmesg output, and 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 2 Brett Witherspoon 2011-01-17 22:51:26 UTC
Created attachment 43902 [details]
Xorg.log
Comment 3 Brett Witherspoon 2011-01-17 22:51:57 UTC
Created attachment 43912 [details]
dmesg
Comment 4 Brett Witherspoon 2011-01-17 22:52:22 UTC
Created attachment 43922 [details]
vbios rom
Comment 5 Alex Deucher 2011-01-20 23:22:26 UTC
Can you dump regs 0x458 and 0x45c using avivotool after resume in the working and non-working states?

(run as root):
avivotool regmatch 0x458
avivotool regmatch 0x45c

You can get avivotool here:
http://cgit.freedesktop.org/~airlied/radeontool/
Comment 6 Alex Deucher 2011-01-20 23:29:07 UTC
Can you also attach your dmesg after resume with this patch:

diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 4a20a62..c19ea3e 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -418,6 +418,8 @@ static void atombios_crtc_program_ss(struct drm_crtc *crtc,
 
        memset(&args, 0, sizeof(args));
 
+       DRM_INFO("atombios_crtc_program_ss: %d\n", enable);
+
        if (ASIC_IS_DCE5(rdev)) {
                args.v3.usSpreadSpectrumAmountFrac = 0;
                args.v3.ucSpreadSpectrumType = ss->type;
Comment 7 Brett Witherspoon 2011-01-21 06:32:24 UTC
Here are the dumps after resume:

v2.6.36.3 ( Working )

avivotool regmatch 0x458:
0x458   0x00000000 (0)
avivotool regmatch 0x45c:
0x45c   0x00000000 (0)

v2.6.37 ( Not Working)

avivotool regmatch 0x458:
0x458   0x00000000 (0)
avivotool regmatch 0x45c:
0x45c   0x00000000 (0)

And dmesg with the patch after resume is attached.
Comment 8 Brett Witherspoon 2011-01-21 06:33:42 UTC
Created attachment 44572 [details]
dmesg after resume with DRM_INFO patch
Comment 9 Alex Deucher 2011-01-24 05:25:57 UTC
The changes in that patch should only affect those regs I asked you to dump, but they are the same before and after.  Can you attach the output of:
avivotool regs all
before and after?
If that gives you any problems, try just dumping the pll regs:
avivotool regmatch <reg>
where <reg> =
0x400
0x404
0x408
0x40c
0x410
0x414
0x418
0x41c
0x420
0x424
0x430
0x434
0x438
0x43c
0x440
0x444
0x448
0x44c
0x450
0x454
Comment 10 kernelbug 2011-01-24 23:03:45 UTC
Created attachment 45042 [details]
avivotool regs all output for working and non working suspend

I am having the same problem on resume with kernel 2.6.37.  I have attached the output of avivotool regs all for a working resume from 2.6.36 and a non-working resume from 2.6.37.  Happy to get you anything else you need.
Comment 11 Brett Witherspoon 2011-01-27 03:26:19 UTC
Created attachment 45232 [details]
regs before resume
Comment 12 Brett Witherspoon 2011-01-27 03:26:45 UTC
Created attachment 45242 [details]
regs after resume
Comment 13 Brett Witherspoon 2011-01-27 03:27:23 UTC
Regs before and after resume ( v2.6.37 ) attached.
Comment 14 Alex Deucher 2011-02-02 18:18:13 UTC
What does the distortion look like?  Flickering display?  garbage on screen?  Can you get a picture?
Comment 15 Alex Deucher 2011-02-02 19:06:27 UTC
I've narrowed it down to a set of possible registers.  Can you try manually setting the following registers after resume and let me know which, if any, fix the problem?

pll controls:
avivotool regset 0x468 0x00000002
avivotool regset 0x46c 0x00000002

uniphy0:
avivotool regset 0x7688 0x19011400
avivotool regset 0x7698 0x10101040

uniphy3:
avivotool regset 0x7aa8 0x19011400
avivotool regset 0x7ab8 0x10101040

uniphy links:
avivotool regset 0x7f20 0x08080100
avivotool regset 0x7f24 0x08080100

Also, it appears you are using two monitors, are both distorted after resume or just one?
Comment 16 Brett Witherspoon 2011-02-02 19:57:05 UTC
Created attachment 46082 [details]
Both monitors

The distortion looks like horizontal lines with flickering. I attached some pictures for you. It occurs on both monitors.

However, the first pll control restores the image:

avivotool regset 0x468 0x00000002
OLD: 0x468 (0468)       0x00000006 (6)
NEW: 0x468 (0468)       0x00000002 (2)

The others don't appear to have any effect.
Comment 17 Brett Witherspoon 2011-02-02 19:58:15 UTC
Created attachment 46092 [details]
Single Monitor
Comment 18 kernelbug 2011-02-02 20:45:43 UTC
The first pll control restores the image for me as well.  I am using the laptop screen (LVDS) and an external LCD.  The distortion occurs only on the laptop screen after resume.
Comment 19 Brett Witherspoon 2011-02-02 21:05:50 UTC
I am sure the logs indicate this, but in case it is relevant I am using the DVI-0 and HDMI-0 connectors for the monitors.
Comment 20 Alex Deucher 2011-02-02 21:59:58 UTC
Thanks. I see what's going on now, but I don't see how that commit could be the one at fault.  I suspect in some s/r cases the registers retained the old state so the bug was not exhibited.  I should have a patch to test soon.
Comment 21 Alex Deucher 2011-02-02 22:32:43 UTC
Created attachment 46142 [details]
fix bios scratch reg settings

This patch should fix the problem. Although I don't understand why this was never an issue before...
Comment 22 Brett Witherspoon 2011-02-03 00:25:35 UTC
OK, that patch does fix the problem. Thank you.
Comment 23 Brett Witherspoon 2011-02-03 00:46:29 UTC
This is probably unrelated but I do have some sluggish response when switching to overview mode with mutter/gnome-shell (r600g). Restarting mutter fixes it, so this seems to be an in issue with mutter/gnome-shell so I will report it there.
Comment 24 Alex Deucher 2011-02-03 00:55:08 UTC
I've sent the patch to Dave for 2.6.38 and 2.6.37 stable.  The gnome-shell problem sounds like a userspace issue; either a bug in mutter or a bug in the 3D driver; probably not kernel related.
Comment 25 Rafael J. Wysocki 2011-02-03 18:50:23 UTC
Handled-By : Alex Deucher <alexdeucher@gmail.com>
Patch : https://bugzilla.kernel.org/attachment.cgi?id=46142
Comment 26 Rafael J. Wysocki 2011-02-12 23:19:20 UTC
Fixed by commit 87364760de5d631390c478fcbac8db1b926e0adf .