From: "Christian König" <deathsimple@vodafone.de>
To: "Michel Dänzer" <michel@daenzer.net>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/radeon: Track the status of a page flip more explicitly
Date: Mon, 30 Jun 2014 11:14:24 +0200 [thread overview]
Message-ID: <53B12A70.20406@vodafone.de> (raw)
In-Reply-To: <1404119554-1907-1-git-send-email-michel@daenzer.net>
Am 30.06.2014 11:12, schrieb Michel Dänzer:
> From: Michel Dänzer <michel.daenzer@amd.com>
>
> This prevents a panic: radeon_crtc_handle_page_flip() could run before
> radeon_flip_work_func(), triggering the BUG_ON() in drm_vblank_put().
>
> Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
>
> v2: Update log message
>
> drivers/gpu/drm/radeon/radeon_display.c | 19 ++++++++++++++-----
> drivers/gpu/drm/radeon/radeon_mode.h | 7 +++++++
> 2 files changed, 21 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
> index 8b575a4..65882cd 100644
> --- a/drivers/gpu/drm/radeon/radeon_display.c
> +++ b/drivers/gpu/drm/radeon/radeon_display.c
> @@ -284,7 +284,6 @@ static void radeon_unpin_work_func(struct work_struct *__work)
> void radeon_crtc_handle_vblank(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;
> u32 update_pending;
> int vpos, hpos;
> @@ -294,8 +293,11 @@ void radeon_crtc_handle_vblank(struct radeon_device *rdev, int crtc_id)
> return;
>
> spin_lock_irqsave(&rdev->ddev->event_lock, flags);
> - work = radeon_crtc->flip_work;
> - if (work == NULL) {
> + if (radeon_crtc->flip_status != RADEON_FLIP_SUBMITTED) {
> + DRM_DEBUG_DRIVER("radeon_crtc->flip_status = %d != "
> + "RADEON_FLIP_SUBMITTED(%d)\n",
> + radeon_crtc->flip_status,
> + RADEON_FLIP_SUBMITTED);
> spin_unlock_irqrestore(&rdev->ddev->event_lock, flags);
> return;
> }
> @@ -343,12 +345,17 @@ void radeon_crtc_handle_flip(struct radeon_device *rdev, int crtc_id)
>
> spin_lock_irqsave(&rdev->ddev->event_lock, flags);
> work = radeon_crtc->flip_work;
> - if (work == NULL) {
> + if (radeon_crtc->flip_status != RADEON_FLIP_SUBMITTED) {
> + DRM_DEBUG_DRIVER("radeon_crtc->flip_status = %d != "
> + "RADEON_FLIP_SUBMITTED(%d)\n",
> + radeon_crtc->flip_status,
> + RADEON_FLIP_SUBMITTED);
> 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;
>
> /* wakeup userspace */
> @@ -475,6 +482,7 @@ static void radeon_flip_work_func(struct work_struct *__work)
> /* do the flip (mmio) */
> radeon_page_flip(rdev, radeon_crtc->crtc_id, base);
>
> + radeon_crtc->flip_status = RADEON_FLIP_SUBMITTED;
> spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
> up_read(&rdev->exclusive_lock);
>
> @@ -543,7 +551,7 @@ static int radeon_crtc_page_flip(struct drm_crtc *crtc,
> /* We borrow the event spin lock for protecting flip_work */
> spin_lock_irqsave(&crtc->dev->event_lock, flags);
>
> - if (radeon_crtc->flip_work) {
> + if (radeon_crtc->flip_status != RADEON_FLIP_NONE) {
> DRM_DEBUG_DRIVER("flip queue: crtc already busy\n");
> spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
> drm_gem_object_unreference_unlocked(&work->old_rbo->gem_base);
> @@ -551,6 +559,7 @@ static int radeon_crtc_page_flip(struct drm_crtc *crtc,
> kfree(work);
> return -EBUSY;
> }
> + radeon_crtc->flip_status = RADEON_FLIP_PENDING;
> radeon_crtc->flip_work = work;
>
> /* update crtc fb */
> diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
> index b59096f..ed6b6e0 100644
> --- a/drivers/gpu/drm/radeon/radeon_mode.h
> +++ b/drivers/gpu/drm/radeon/radeon_mode.h
> @@ -301,6 +301,12 @@ struct radeon_atom_ss {
> uint16_t amount;
> };
>
> +enum radeon_flip_status {
> + RADEON_FLIP_NONE,
> + RADEON_FLIP_PENDING,
> + RADEON_FLIP_SUBMITTED
> +};
> +
> struct radeon_crtc {
> struct drm_crtc base;
> int crtc_id;
> @@ -326,6 +332,7 @@ struct radeon_crtc {
> /* page flipping */
> struct workqueue_struct *flip_queue;
> struct radeon_flip_work *flip_work;
> + enum radeon_flip_status flip_status;
> /* pll sharing */
> struct radeon_atom_ss ss;
> bool ss_enabled;
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2014-06-30 9:14 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-26 9:29 [PATCH 1/2] drm/radeon: Only enable and handle pageflip interrupts when needed Michel Dänzer
2014-06-26 9:29 ` [PATCH 2/2] drm/radeon: Track the status of a page flip more explicitly Michel Dänzer
2014-06-30 9:12 ` [PATCH v2] " Michel Dänzer
2014-06-30 9:14 ` Christian König [this message]
2014-07-01 16:23 ` Alex Deucher
2014-06-26 10:39 ` [PATCH 1/2] drm/radeon: Only enable and handle pageflip interrupts when needed Christian König
2014-06-26 11:51 ` Dieter Nützel
2014-06-27 0:53 ` Dieter Nützel
2014-06-27 1:03 ` Michel Dänzer
2014-06-27 1:08 ` Dieter Nützel
2014-06-27 2:06 ` Dieter Nützel
2014-06-27 3:03 ` Michel Dänzer
2014-06-27 3:17 ` Michel Dänzer
2014-06-27 2:58 ` Michel Dänzer
2014-06-27 8:18 ` Christian König
2014-06-27 9:44 ` Michel Dänzer
2014-06-27 10:47 ` Christian König
2014-06-30 9:34 ` Michel Dänzer
2014-06-30 12:31 ` Christian König
2014-06-30 16:22 ` Dieter Nützel
2014-07-01 8:14 ` [PATCH 1/2] drm/radeon: Program page flips to execute in hblank instead of vblank Michel Dänzer
2014-07-01 8:14 ` [PATCH 2/2] drm/radeon: Remove radeon_kms_pflip_irq_get/put() Michel Dänzer
2014-07-01 10:12 ` [PATCH 1/2] drm/radeon: Program page flips to execute in hblank instead of vblank Christian König
2014-07-02 3:55 ` [PATCH v2 " Michel Dänzer
2014-07-02 3:55 ` [PATCH v2 2/2] drm/radeon: Remove radeon_kms_pflip_irq_get/put() and the pflip atomic Michel Dänzer
2014-07-02 10:10 ` [PATCH 1/2] drm/radeon: Move pinning the BO back to radeon_crtc_page_flip() Michel Dänzer
2014-07-02 10:10 ` [PATCH 2/2] drm/radeon: Complete page flip even if waiting on the BO fence fails Michel Dänzer
2014-07-02 11:42 ` [PATCH 1/2] drm/radeon: Move pinning the BO back to radeon_crtc_page_flip() Christian König
2014-07-02 11:35 ` [PATCH v2 1/2] drm/radeon: Program page flips to execute in hblank instead of vblank Christian König
2014-07-01 16:46 ` [PATCH " Dieter Nützel
2014-07-02 0:29 ` Michel Dänzer
2014-07-02 3:01 ` Dieter Nützel
2014-07-02 3:11 ` Michel Dänzer
2014-07-02 3:52 ` Michel Dänzer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53B12A70.20406@vodafone.de \
--to=deathsimple@vodafone.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=michel@daenzer.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox