diff mbox

[1/2] Revert "drm/radeon: remove drm_vblank_get|put from pflip handling"

Message ID 53AA80D7.4080404@daenzer.net (mailing list archive)
State New, archived
Headers show

Commit Message

Michel Dänzer June 25, 2014, 7:57 a.m. UTC
On 25.06.2014 03:13, Dieter Nützel wrote:
> Am 24.06.2014 12:05, schrieb Michel Dänzer:
>> On 24.06.2014 05:32, Dieter Nützel wrote:
>>> Am 23.06.2014 21:46, schrieb Dieter Nützel:
>>>> Am 23.06.2014 11:34, schrieb Michel Dänzer:
>>>>> On 18.06.2014 18:14, Christian König wrote:
>>>>>> Am 18.06.2014 07:53, schrieb Michel Dänzer:
>>>>>>>
>>>>>>>   (WW) RADEON(0): radeon_dri2_flip_event_handler: Pageflip
>>>>>>> completion
>>>>>>> event has impossible msc [x-1] < target_msc [x]
>>> [...]
>>> I can reliable generate such lines in Xorg.0.log with KWin cube desktop
>>> effect.
>>>
>>> Rotate screens with mouse wheel or screen switcher => new entry in
>>> Xorg.0.log. If it happens I notice ('see') flip delay.
>>
>> I was only able to reproduce it a couple of times even with that, but not
>> at all yet with the patch below. Does it help for you as well?
> 
> Will try in the next run.
> 
> My daughter generated kernel crash for us.;-)
> See would open up a zoom image in Konqi of a new Waveboard for here girl
> friends...
> 
> But I could only take images with my mobile.
> kernel BUG at drivers/gpu/drm/drm_irq.c:976!

I was able to reproduce all these issues, and the attached three patches
fix them for me. Please let me know if you can still trigger the panic
or the diagnostic error messages in patch 2 somehow. If everything works
fine for you as well with these, I'll submit them with the error
messages in patch 2 changed to debug messages.

Comments

Dieter Nützel June 25, 2014, 11:34 p.m. UTC | #1
Am 25.06.2014 09:57, schrieb Michel Dänzer:
> On 25.06.2014 03:13, Dieter Nützel wrote:
>> Am 24.06.2014 12:05, schrieb Michel Dänzer:
>>> On 24.06.2014 05:32, Dieter Nützel wrote:
>>>> Am 23.06.2014 21:46, schrieb Dieter Nützel:
>>>>> Am 23.06.2014 11:34, schrieb Michel Dänzer:
>>>>>> On 18.06.2014 18:14, Christian König wrote:
>>>>>>> Am 18.06.2014 07:53, schrieb Michel Dänzer:
>>>>>>>> 
>>>>>>>>   (WW) RADEON(0): radeon_dri2_flip_event_handler: Pageflip
>>>>>>>> completion
>>>>>>>> event has impossible msc [x-1] < target_msc [x]
>>>> [...]
>>>> I can reliable generate such lines in Xorg.0.log with KWin cube 
>>>> desktop
>>>> effect.
>>>> 
>>>> Rotate screens with mouse wheel or screen switcher => new entry in
>>>> Xorg.0.log. If it happens I notice ('see') flip delay.
>>> 
>>> I was only able to reproduce it a couple of times even with that, but 
>>> not
>>> at all yet with the patch below. Does it help for you as well?
>> 
>> Will try in the next run.

It helped half way as reported already. (Second half below.) ;-)

>> My daughter generated kernel crash for us.;-)
>> See would open up a zoom image in Konqi of a new Waveboard for here 
>> girl
>> friends...
>> 
>> But I could only take images with my mobile.
>> kernel BUG at drivers/gpu/drm/drm_irq.c:976!
> 
> I was able to reproduce all these issues, and the attached three 
> patches
> fix them for me. Please let me know if you can still trigger the panic
> or the diagnostic error messages in patch 2 somehow. If everything 
> works
> fine for you as well with these, I'll submit them with the error
> messages in patch 2 changed to debug messages.

Tested-by: Dieter@nuetzel-hh.de on top of 3.16-rc2.
Can't trigger any of the above problems with your three patches applied.

With your former single patch I got three hangs during boot up in the 
morning.
Nothing in the logs or catchable. Screen showed openSUSE plymouth
startup logo. - But no RAID1 rebuild needed.

Shouldn't this go into -rc3 if Christian and Alex ACKed it?

Greetings,
    Dieter
Michel Dänzer June 26, 2014, 9:34 a.m. UTC | #2
On 26.06.2014 08:34, Dieter Nützel wrote:
> Am 25.06.2014 09:57, schrieb Michel Dänzer:
>> On 25.06.2014 03:13, Dieter Nützel wrote:
>>> Am 24.06.2014 12:05, schrieb Michel Dänzer:
>>>> On 24.06.2014 05:32, Dieter Nützel wrote:
>>>>> Am 23.06.2014 21:46, schrieb Dieter Nützel:
>>>>>> Am 23.06.2014 11:34, schrieb Michel Dänzer:
>>>>>>> On 18.06.2014 18:14, Christian König wrote:
>>>>>>>> Am 18.06.2014 07:53, schrieb Michel Dänzer:
>>>>>>>>>
>>>>>>>>>   (WW) RADEON(0): radeon_dri2_flip_event_handler: Pageflip
>>>>>>>>> completion
>>>>>>>>> event has impossible msc [x-1] < target_msc [x]
>>>>> [...]
>>>>> I can reliable generate such lines in Xorg.0.log with KWin cube
>>>>> desktop
>>>>> effect.
>>>>>
>>>>> Rotate screens with mouse wheel or screen switcher => new entry in
>>>>> Xorg.0.log. If it happens I notice ('see') flip delay.
>>>>
>>>> [...]
>>>
>>> My daughter generated kernel crash for us.;-)
>>> See would open up a zoom image in Konqi of a new Waveboard for here girl
>>> friends...
>>>
>>> But I could only take images with my mobile.
>>> kernel BUG at drivers/gpu/drm/drm_irq.c:976!
>>
>> I was able to reproduce all these issues, and the attached three patches
>> fix them for me. Please let me know if you can still trigger the panic
>> or the diagnostic error messages in patch 2 somehow. If everything works
>> fine for you as well with these, I'll submit them with the error
>> messages in patch 2 changed to debug messages.
> 
> Tested-by: Dieter@nuetzel-hh.de on top of 3.16-rc2.
> Can't trigger any of the above problems with your three patches applied.

Great, thanks for testing. I've submitted the first two patches for
inclusion.

I'm still pondering if the third patch is the right thing to do or even
necessary. Maybe we should instead fix the X radeon driver to deal more
gracefully with page flips completing earlier than expected. E.g. weston
doesn't seem to have any trouble with that.


> Shouldn't this go into -rc3 if Christian and Alex ACKed it?

These fixes should go in before the 3.16 release, yes. And I don't see
why they wouldn't.
diff mbox

Patch

From 697c07badc5930708d04f55ae5e8ac3561edc478 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <michel.daenzer@amd.com>
Date: Tue, 24 Jun 2014 18:38:54 +0900
Subject: [PATCH 3/3] drm/radeon: Avoid sending page flip completion event
 prematurely
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Userspace expects page flips to only complete after the next vertical blank
interval. Don't send the page flip completion event before the vertical
blank sequence number has been incremented at least once.

Hopefully avoids lines like

 (WW) RADEON(0): radeon_dri2_flip_event_handler: Pageflip completion event has impossible msc [x-1] < target_msc [x]

in the Xorg log file, and any corresponding breakage.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
---
 drivers/gpu/drm/radeon/radeon_display.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 69e1efd..f1bf514 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -337,11 +337,15 @@  void radeon_crtc_handle_flip(struct radeon_device *rdev, int crtc_id)
 	struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id];
 	struct radeon_flip_work *work;
 	unsigned long flags;
+	struct timeval vblank_time;
+	u32 vblank_seq;
 
 	/* this can happen at init */
 	if (radeon_crtc == NULL)
 		return;
 
+	vblank_seq = drm_vblank_count_and_time(rdev->ddev, crtc_id, &vblank_time);
+
 	spin_lock_irqsave(&rdev->ddev->event_lock, flags);
 	work = radeon_crtc->flip_work;
 	if (radeon_crtc->flip_status != RADEON_FLIP_SUBMITTED) {
@@ -352,6 +356,14 @@  void radeon_crtc_handle_flip(struct radeon_device *rdev, int crtc_id)
 		return;
 	}
 
+	work = radeon_crtc->flip_work;
+	if ((vblank_seq - work->event->event.sequence) > (1<<23)) {
+		DRM_DEBUG_DRIVER("vblank_seq = %u < %u\n",
+				 vblank_seq, work->event->event.sequence);
+		spin_unlock_irqrestore(&rdev->ddev->event_lock, flags);
+		return;
+	}
+
 	/* Pageflip completed. Clean up. */
 	radeon_crtc->flip_status = RADEON_FLIP_NONE;
 	radeon_crtc->flip_work = NULL;
@@ -515,6 +527,7 @@  static int radeon_crtc_page_flip(struct drm_crtc *crtc,
 	struct radeon_framebuffer *new_radeon_fb;
 	struct drm_gem_object *obj;
 	struct radeon_flip_work *work;
+	struct timeval vblank_time;
 	unsigned long flags;
 
 	work = kzalloc(sizeof *work, GFP_KERNEL);
@@ -565,6 +578,10 @@  static int radeon_crtc_page_flip(struct drm_crtc *crtc,
 
 	spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
 
+	work->event->event.sequence =
+		drm_vblank_count_and_time(crtc->dev, radeon_crtc->crtc_id,
+					  &vblank_time) + 1;
+
 	queue_work(radeon_crtc->flip_queue, &work->flip_work);
 
 	return 0;
-- 
2.0.0