Bug 64610

Summary: [845g regression] Suspend does not work on 845g with kernel 3.8.0-rc6
Product: DRI Reporter: clockley1 <clockley1>
Component: DRM/IntelAssignee: Chris Wilson <chris>
Status: CLOSED WORKSFORME QA Contact: Intel GFX Bugs mailing list <intel-gfx-bugs>
Severity: normal    
Priority: high CC: ballogyor
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Xorg log file.
none
Workaround that works on my system
none
next patch
none
fix up ring cleanup none

Description clockley1 2013-05-15 02:14:37 UTC
Created attachment 79319 [details]
Xorg log file.

Commit 'https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=b45305fce5bb1abec263fcff9d81ebecd6306ede' breaks suspend on 845g running 3.8.0-rc6 kernel(sna and uxa are affected, though most times uxa crashes before I get to suspend, have not tested modesetting driver). I doubt reverting this fixes the underlining cause though as I tried in on a newer kernel 'https://www.kernel.org/pub/linux/kernel/v3.x/testing/linux-3.10-rc1.tar.xz' and it did not work (It does work on the 3.8.0-rc6 kernel). It was mostly by hand on the latter, so there is a chance I misapplied it.

lspci -v|grep -i vga:
00:02.0 VGA compatible controller: Intel Corporation 82845G/GL[Brookdale-G]/GE Chipset Integrated Graphics Device (rev 01) (prog-if 00 [VGA controller])

uname -a:

Linux localhost.localdomain 3.8.0-rc6 #68 Thu May 9 18:29:33 EDT 2013 i686 i686 i386 GNU/Linux

cat /etc/fedora-release:
Fedora release 17 (Beefy Miracle)

glxinfo:
name of display: :0.0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
    GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, 
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_INTEL_swap_event, 
    GLX_MESA_copy_sub_buffer, GLX_OML_swap_method, GLX_SGIS_multisample, 
    GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, 
    GLX_SGI_swap_control
client glx vendor string: Mesa Project and SGI
client glx version string: 1.4
client glx extensions:
    GLX_ARB_create_context, GLX_ARB_create_context_profile, 
    GLX_ARB_get_proc_address, GLX_ARB_multisample, 
    GLX_EXT_create_context_es2_profile, GLX_EXT_framebuffer_sRGB, 
    GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, 
    GLX_EXT_visual_rating, GLX_INTEL_swap_event, GLX_MESA_copy_sub_buffer, 
    GLX_MESA_multithread_makecurrent, GLX_MESA_swap_control, 
    GLX_OML_swap_method, GLX_OML_sync_control, GLX_SGIS_multisample, 
    GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, 
    GLX_SGI_make_current_read, GLX_SGI_swap_control, GLX_SGI_video_sync
GLX version: 1.4
GLX extensions:
    GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_import_context, 
    GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, GLX_EXT_visual_rating, 
    GLX_MESA_copy_sub_buffer, GLX_MESA_multithread_makecurrent, 
    GLX_MESA_swap_control, GLX_OML_swap_method, GLX_OML_sync_control, 
    GLX_SGIS_multisample, GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, 
    GLX_SGIX_visual_select_group, GLX_SGI_make_current_read, 
    GLX_SGI_swap_control, GLX_SGI_video_sync
OpenGL vendor string: Tungsten Graphics, Inc
OpenGL renderer string: Mesa DRI Intel(R) 845G 
OpenGL version string: 1.3 Mesa 8.0.4
OpenGL extensions:
    GL_3DFX_texture_compression_FXT1, GL_APPLE_object_purgeable, 
    GL_APPLE_packed_pixels, GL_APPLE_vertex_array_object, GL_ARB_copy_buffer, 
    GL_ARB_draw_buffers, GL_ARB_draw_elements_base_vertex, 
    GL_ARB_explicit_attrib_location, GL_ARB_framebuffer_object, 
    GL_ARB_half_float_pixel, GL_ARB_map_buffer_range, GL_ARB_multisample, 
    GL_ARB_multitexture, GL_ARB_pixel_buffer_object, GL_ARB_point_parameters, 
    GL_ARB_point_sprite, GL_ARB_provoking_vertex, GL_ARB_robustness, 
    GL_ARB_sampler_objects, GL_ARB_shader_objects, 
    GL_ARB_shading_language_100, GL_ARB_sync, GL_ARB_texture_border_clamp, 
    GL_ARB_texture_compression, GL_ARB_texture_cube_map, 
    GL_ARB_texture_env_add, GL_ARB_texture_env_combine, 
    GL_ARB_texture_env_crossbar, GL_ARB_texture_env_dot3, 
    GL_ARB_texture_mirrored_repeat, GL_ARB_texture_rectangle, 
    GL_ARB_transpose_matrix, GL_ARB_vertex_array_object, 
    GL_ARB_vertex_buffer_object, GL_ARB_vertex_program, GL_ARB_vertex_shader, 
    GL_ARB_window_pos, GL_ATI_blend_equation_separate, GL_ATI_draw_buffers, 
    GL_EXT_abgr, GL_EXT_bgra, GL_EXT_blend_color, 
    GL_EXT_blend_equation_separate, GL_EXT_blend_func_separate, 
    GL_EXT_blend_minmax, GL_EXT_blend_subtract, GL_EXT_compiled_vertex_array, 
    GL_EXT_copy_texture, GL_EXT_draw_range_elements, GL_EXT_fog_coord, 
    GL_EXT_framebuffer_blit, GL_EXT_framebuffer_multisample, 
    GL_EXT_framebuffer_object, GL_EXT_gpu_program_parameters, 
    GL_EXT_multi_draw_arrays, GL_EXT_packed_depth_stencil, 
    GL_EXT_packed_pixels, GL_EXT_pixel_buffer_object, GL_EXT_point_parameters, 
    GL_EXT_polygon_offset, GL_EXT_provoking_vertex, GL_EXT_rescale_normal, 
    GL_EXT_secondary_color, GL_EXT_separate_shader_objects, 
    GL_EXT_separate_specular_color, GL_EXT_stencil_wrap, GL_EXT_subtexture, 
    GL_EXT_texture, GL_EXT_texture3D, GL_EXT_texture_compression_dxt1, 
    GL_EXT_texture_compression_s3tc, GL_EXT_texture_cube_map, 
    GL_EXT_texture_edge_clamp, GL_EXT_texture_env_add, 
    GL_EXT_texture_env_combine, GL_EXT_texture_env_dot3, 
    GL_EXT_texture_filter_anisotropic, GL_EXT_texture_lod_bias, 
    GL_EXT_texture_object, GL_EXT_texture_rectangle, GL_EXT_vertex_array, 
    GL_IBM_multimode_draw_arrays, GL_IBM_rasterpos_clip, 
    GL_IBM_texture_mirrored_repeat, GL_INGR_blend_func_separate, 
    GL_MESA_pack_invert, GL_MESA_window_pos, GL_MESA_ycbcr_texture, 
    GL_NV_blend_square, GL_NV_light_max_exponent, GL_NV_packed_depth_stencil, 
    GL_NV_texgen_reflection, GL_NV_texture_rectangle, GL_NV_vertex_program, 
    GL_NV_vertex_program1_1, GL_OES_EGL_image, GL_OES_read_format, 
    GL_S3_s3tc, GL_SGIS_generate_mipmap, GL_SGIS_texture_border_clamp, 
    GL_SGIS_texture_edge_clamp, GL_SGIS_texture_lod, GL_SUN_multi_draw_arrays

1 GLX Visuals
    visual  x   bf lv rg d st  colorbuffer  sr ax dp st accumbuffer  ms  cav
  id dep cl sp  sz l  ci b ro  r  g  b  a F gb bf th cl  r  g  b  a ns b eat
----------------------------------------------------------------------------
0x060 32 tc  0  32  0 r  y .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None

48 GLXFBConfigs:
    visual  x   bf lv rg d st  colorbuffer  sr ax dp st accumbuffer  ms  cav
  id dep cl sp  sz l  ci b ro  r  g  b  a F gb bf th cl  r  g  b  a ns b eat
----------------------------------------------------------------------------
0x061  0 tc  0  16  0 r  . .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x062  0 tc  0  16  0 r  y .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x063  0 tc  0  16  0 r  y .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x064  0 tc  0  16  0 r  . .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x065  0 tc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x066  0 tc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x067  0 tc  0  24  0 r  . .   8  8  8  0 .  .  0  0  0  0  0  0  0  0 0 None
0x068  0 tc  0  24  0 r  y .   8  8  8  0 .  .  0  0  0  0  0  0  0  0 0 None
0x069  0 tc  0  24  0 r  y .   8  8  8  0 .  .  0  0  0  0  0  0  0  0 0 None
0x06a  0 tc  0  24  0 r  . .   8  8  8  0 .  .  0 24  8  0  0  0  0  0 0 None
0x06b  0 tc  0  24  0 r  y .   8  8  8  0 .  .  0 24  8  0  0  0  0  0 0 None
0x06c  0 tc  0  24  0 r  y .   8  8  8  0 .  .  0 24  8  0  0  0  0  0 0 None
0x06d  0 tc  0  32  0 r  . .   8  8  8  8 .  .  0  0  0  0  0  0  0  0 0 None
0x06e  0 tc  0  32  0 r  y .   8  8  8  8 .  .  0  0  0  0  0  0  0  0 0 None
0x06f  0 tc  0  32  0 r  y .   8  8  8  8 .  .  0  0  0  0  0  0  0  0 0 None
0x070  0 tc  0  32  0 r  . .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
0x071 32 tc  0  32  0 r  y .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
0x072  0 tc  0  32  0 r  y .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
0x073  0 tc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x074  0 tc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0 16 16 16  0  0 0 Slow
0x075  0 tc  0  24  0 r  y .   8  8  8  0 .  .  0 24  8  0  0  0  0  0 0 None
0x076  0 tc  0  24  0 r  y .   8  8  8  0 .  .  0 24  8 16 16 16  0  0 0 Slow
0x077  0 tc  0  32  0 r  y .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
0x078  0 tc  0  32  0 r  y .   8  8  8  8 .  .  0 24  8 16 16 16 16  0 0 Slow
0x079  0 dc  0  16  0 r  . .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x07a  0 dc  0  16  0 r  y .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x07b  0 dc  0  16  0 r  y .   5  6  5  0 .  .  0  0  0  0  0  0  0  0 0 None
0x07c  0 dc  0  16  0 r  . .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x07d  0 dc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x07e  0 dc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x07f  0 dc  0  24  0 r  . .   8  8  8  0 .  .  0  0  0  0  0  0  0  0 0 None
0x080  0 dc  0  24  0 r  y .   8  8  8  0 .  .  0  0  0  0  0  0  0  0 0 None
0x081  0 dc  0  24  0 r  y .   8  8  8  0 .  .  0  0  0  0  0  0  0  0 0 None
0x082  0 dc  0  24  0 r  . .   8  8  8  0 .  .  0 24  8  0  0  0  0  0 0 None
0x083  0 dc  0  24  0 r  y .   8  8  8  0 .  .  0 24  8  0  0  0  0  0 0 None
0x084  0 dc  0  24  0 r  y .   8  8  8  0 .  .  0 24  8  0  0  0  0  0 0 None
0x085  0 dc  0  32  0 r  . .   8  8  8  8 .  .  0  0  0  0  0  0  0  0 0 None
0x086  0 dc  0  32  0 r  y .   8  8  8  8 .  .  0  0  0  0  0  0  0  0 0 None
0x087  0 dc  0  32  0 r  y .   8  8  8  8 .  .  0  0  0  0  0  0  0  0 0 None
0x088  0 dc  0  32  0 r  . .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
0x089  0 dc  0  32  0 r  y .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
0x08a  0 dc  0  32  0 r  y .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
0x08b  0 dc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0  0  0  0  0  0 0 None
0x08c  0 dc  0  16  0 r  y .   5  6  5  0 .  .  0 16  0 16 16 16  0  0 0 Slow
0x08d  0 dc  0  24  0 r  y .   8  8  8  0 .  .  0 24  8  0  0  0  0  0 0 None
0x08e  0 dc  0  24  0 r  y .   8  8  8  0 .  .  0 24  8 16 16 16  0  0 0 Slow
0x08f  0 dc  0  32  0 r  y .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
0x090  0 dc  0  32  0 r  y .   8  8  8  8 .  .  0 24  8 16 16 16 16  0 0 Slow
Comment 1 Daniel Vetter 2013-05-20 20:12:23 UTC
How exactly does your machine go down when failing at suspend/resume? Hard-hang, only unuseable gpu or something else?

To test whether disabling the mentioned patch fixes things you can change the

- if (flags & I915_DISPATCH_PINNED) {
+ if (1) {

condition in i830_dispatch_execbuffer.
Comment 2 clockley1 2013-05-21 02:14:42 UTC
It wakes up but the screen is blank and the caps lock key does not work, did not test over network.
Comment 3 Daniel Vetter 2013-06-16 11:51:22 UTC
To check the manual revert can you please try this diff on top of 3.10?

diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index e51ab55..2f91c1f 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1117,7 +1117,7 @@ i830_dispatch_execbuffer(struct intel_ring_buffer *ring,
 {
        int ret;
 
-       if (flags & I915_DISPATCH_PINNED) {
+       if (1 || flags & I915_DISPATCH_PINNED) {
                ret = intel_ring_begin(ring, 4);
                if (ret)
                        return ret;
Comment 4 clockley1 2013-06-18 01:42:24 UTC
(In reply to comment #3)
> To check the manual revert can you please try this diff on top of 3.10?
> 
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c
> b/drivers/gpu/drm/i915/intel_ringbuffer.c
> index e51ab55..2f91c1f 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> @@ -1117,7 +1117,7 @@ i830_dispatch_execbuffer(struct intel_ring_buffer
> *ring,
>  {
>         int ret;
>  
> -       if (flags & I915_DISPATCH_PINNED) {
> +       if (1 || flags & I915_DISPATCH_PINNED) {
>                 ret = intel_ring_begin(ring, 4);
>                 if (ret)
>                         return ret;

Downloaded 'https://www.kernel.org/pub/linux/kernel/v3.x/testing/linux-3.10-rc6.tar.xz' and compiled with patch; this kernel does not even suspend. The screen stays on and displays screen corruption not unlike a hung gpu.
Comment 5 clockley1 2013-06-18 12:41:52 UTC
Created attachment 81001 [details] [review]
Workaround that works on my system

This patch requires the "if (1 || flags & I915_DISPATCH_PINNED) {" patch.
Comment 6 clockley1 2013-06-18 12:48:30 UTC
Created attachment 81002 [details] [review]
next patch

This patch requires the last patch.
Comment 7 clockley1 2013-06-18 13:00:21 UTC
I have not thoroughly tested the patches. They may have intended side effects and probably break other hardware.
Comment 8 Chris Wilson 2013-06-24 08:11:17 UTC
*** Bug 66099 has been marked as a duplicate of this bug. ***
Comment 9 Chris Wilson 2013-06-24 11:12:12 UTC
Can you please try:

diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/inte
index 1d5d613..d1b3cc1 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1715,7 +1715,9 @@ int intel_init_render_ring_buffer(struct drm_device *dev)
                struct drm_i915_gem_object *obj;
                int ret;
 
-               obj = i915_gem_alloc_object(dev, I830_BATCH_LIMIT);
+               obj = i915_gem_object_create_stolen(dev, I830_BATCH_LIMIT);
+               if (obj == NULL)
+                       obj = i915_gem_alloc_object(dev, I830_BATCH_LIMIT);
                if (obj == NULL) {
                        DRM_ERROR("Failed to allocate batch bo\n");
                        return -ENOMEM;

Though I suspect we may need a SRC_COLOR command to clear the ring->private on every ring init.
Comment 10 clockley1 2013-07-02 02:06:04 UTC
(In reply to comment #9)
> Can you please try:
> 
> diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c
> b/drivers/gpu/drm/i915/inte
> index 1d5d613..d1b3cc1 100644
> --- a/drivers/gpu/drm/i915/intel_ringbuffer.c
> +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
> @@ -1715,7 +1715,9 @@ int intel_init_render_ring_buffer(struct drm_device
> *dev)
>                 struct drm_i915_gem_object *obj;
>                 int ret;
>  
> -               obj = i915_gem_alloc_object(dev, I830_BATCH_LIMIT);
> +               obj = i915_gem_object_create_stolen(dev, I830_BATCH_LIMIT);
> +               if (obj == NULL)
> +                       obj = i915_gem_alloc_object(dev, I830_BATCH_LIMIT);
>                 if (obj == NULL) {
>                         DRM_ERROR("Failed to allocate batch bo\n");
>                         return -ENOMEM;
> 
> Though I suspect we may need a SRC_COLOR command to clear the ring->private
> on every ring init.

Sorry about the delay, unfortunately this patch does not work, at least on this machine.
Comment 11 Daniel Vetter 2013-07-03 10:13:46 UTC
Created attachment 81948 [details] [review]
fix up ring cleanup

Can you please test the attached patch? Please test this on the first broken kernel, not the latest one in case we've accidentally broken something else in between.
Comment 12 Chris Wilson 2013-07-05 19:24:33 UTC
You need Daniel's ring cleanup patch, and I think (the second chunk) of:

diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index d7ca64e..738f54b 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1281,6 +1281,11 @@ static int intel_init_ring_buffer(struct drm_device *dev,
 			return ret;
 	}
 
+	/* Stop the ring if it's running. */
+	I915_WRITE_CTL(ring, 0);
+	I915_WRITE_HEAD(ring, 0);
+	ring->write_tail(ring, 0);
+
 	obj = NULL;
 	if (!HAS_LLC(dev))
 		obj = i915_gem_object_create_stolen(dev, ring->size);
@@ -1821,10 +1826,17 @@ int intel_init_render_ring_buffer(struct drm_device *dev)
 			return -ENOMEM;
 		}
 
-		ret = i915_gem_object_pin(obj, 0, true, false);
+		ret = i915_gem_object_pin(obj, 0, false, false);
 		if (ret != 0) {
 			drm_gem_object_unreference(&obj->base);
-			DRM_ERROR("Failed to ping batch bo\n");
+			DRM_ERROR("Failed to pin batch bo\n");
+			return ret;
+		}
+
+		ret = i915_gem_object_set_to_gtt_domain(obj, true);
+		if (ret) {
+			drm_gem_object_unreference(&obj->base);
+			DRM_ERROR("Failed to flush batch bo\n");
 			return ret;
 		}
Comment 13 Daniel Vetter 2013-07-05 21:26:46 UTC
Does that mean I get a tested-by from you Chris on my patch?
Comment 14 Chris Wilson 2013-07-11 10:38:00 UTC
In the maybe we need to clear the bounce buffer vein:

commit 388b0e149e6de91b3800adbb5aa02f20b5a80e5d
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Jul 11 11:34:42 2013 +0100

    drm/i915: Clear the workaround batch bo for gen2

Can you please test with my userptr branch at http://cgit.freedesktop.org/~ickle/linux-2.6 ?
Comment 15 Chris Wilson 2013-07-11 11:36:05 UTC
No need to test as that branch died upon resume here.
Comment 16 Balló György 2013-08-07 10:53:47 UTC
The resume from suspend is still broken on 845G with kernel version 3.10.5. I can't see anything, just a blank screen. The last working version is 3.7.10.
Comment 17 Chris Wilson 2013-09-23 17:28:10 UTC
Note to self, -nightly still broken. And there is a hang during suspend if using glxgears -fullscreen.
Comment 18 clockley1 2014-01-15 04:25:53 UTC
The latest kernel from "http://cgit.freedesktop.org/~danvet/drm-intel/?h=drm-intel-next" works for me.
Comment 19 Chris Wilson 2014-01-15 12:02:59 UTC
(In reply to comment #18)
> The latest kernel from
> "http://cgit.freedesktop.org/~danvet/drm-intel/?h=drm-intel-next" works for
> me.

Are you happy to close this as working now but cause unknown?
Comment 20 clockley1 2014-01-16 03:20:02 UTC
Sure, that's fine.

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.