From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 7/9] drm/omap: fix omap_crtc_flush() to handle the workqueue
Date: Tue, 9 Sep 2014 10:07:46 +0300 [thread overview]
Message-ID: <540EA742.3080109@ti.com> (raw)
In-Reply-To: <20140908133139.GZ15520@phenom.ffwll.local>
[-- Attachment #1.1: Type: text/plain, Size: 3225 bytes --]
On 08/09/14 16:31, Daniel Vetter wrote:
> On Mon, Sep 08, 2014 at 04:03:18PM +0300, Tomi Valkeinen wrote:
>> On 03/09/14 17:27, Daniel Vetter wrote:
>>> On Wed, Sep 03, 2014 at 02:55:08PM +0300, Tomi Valkeinen wrote:
>>>> omap_crtc_flush() is used to wait for scheduled work to be done for the
>>>> give crtc. However, it's not quite right at the moment.
>>>>
>>>> omap_crtc_flush() does wait for work that is ran via vsync irq to be
>>>> done. However, work is also queued to the driver's priv->wq workqueue,
>>>> which is not handled by omap_crtc_flush().
>>>>
>>>> Improve omap_crtc_flush() to flush the workqueue so that work there will
>>>> be ran.
>>>>
>>>> This fixes a race issue on module unload, where an unpin work may be on
>>>> the work queue, but does not get ran before drm core starts tearing the
>>>> driver down, leading to a WARN.
>>>>
>>>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
>>>
>>> I didn't really dig into details, but isn't that the same workqueue as
>>> used by the async modeset code? So the same deadlocks might happen ...
>>
>> Yes, we have just one workqueue in the driver.
>>
>> Hmm, deadlocks with what lock? The modeconfig or crtc->mutex? I don't
>> think they are locked at any place where omap_crtc_flush is called.
>
> Oh, I presumed you're using _flush in the relevant modeset functions - we
No. That's the locking issue again. We can't flush when holding the crtc
mutex, as the works in the workqueue also try to grab it...
> do that in i915 to make sure that all the pageflips and other stuff
> completed before we do another modeset. But omap only calls this at driver
> unload, so no direct problem.
At the moment yes, but in this series I add the same omap_crtc_flush()
call to two new places: dev_preclose and omap_crtc_commit. Of which the
omap_crtc_commit is the problematic one, discussed in the mail thread
for patch 4.
>>> lockdep won't complain though since you essentially open-code a
>>> workqueue_flush, and lockdep also doesn't complain about all possible
>>> deadlocks (due to some design issues with lockdep).
>>
>> What do you mean "open-code a workqueue_flush"?. I use flush_workqueue
>> there. We have two things to wait for: work on the workqueue and work
>> which is triggered by the vsync irq. So we loop and test for both of
>> those, until there's no more work.
>
> Oops, missed that. Ordering looks wrong though since if the irq can latch
> the workqueue you need to wait for irqs to happen first before flushing.
> And obviously queue the work before signalling the completion of the
> interrupt. But since this seems to lack locking anyway and is only used
> for unload it doesn't really matter.
Yeah, well, the workqueue can create work for the irq also. I don't know
if it does, currently, but I think it's safer to presume that both
workqueue and the irq can create work to the other.
But that's why I have a loop there. So we flush, then check if there is
work for the irq. If yes, sleep a bit and go back to start. So if the
irq work created new work for the wq, we flush that. And if that work
created new work for the irq, we check that again. Etc.
Tomi
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2014-09-09 7:08 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-03 11:55 [PATCH 1/9] drm/omap: fix encoder-crtc mapping Tomi Valkeinen
2014-09-03 11:55 ` [PATCH 2/9] drm/omap: page_flip: return -EBUSY if flip pending Tomi Valkeinen
2014-09-03 11:55 ` [PATCH 3/9] drm/omap: fix race issue with vsync irq and apply Tomi Valkeinen
2014-09-03 11:55 ` [PATCH 4/9] drm/omap: make modesetting synchronous Tomi Valkeinen
2014-09-03 14:25 ` Daniel Vetter
2014-09-03 15:05 ` Rob Clark
2014-09-03 15:21 ` Daniel Vetter
2014-09-03 16:00 ` Rob Clark
2014-09-03 19:20 ` Daniel Vetter
2014-09-08 12:53 ` Tomi Valkeinen
2014-09-08 13:24 ` Daniel Vetter
2014-09-08 13:39 ` Rob Clark
2014-09-08 13:50 ` Daniel Vetter
2014-09-08 13:57 ` Rob Clark
2014-09-03 11:55 ` [PATCH 5/9] drm/omap: clear omap_obj->paddr in omap_gem_put_paddr() Tomi Valkeinen
2014-09-03 11:55 ` [PATCH 6/9] drm/omap: add pin refcounting to omap_framebuffer Tomi Valkeinen
2014-09-03 11:55 ` [PATCH 7/9] drm/omap: fix omap_crtc_flush() to handle the workqueue Tomi Valkeinen
2014-09-03 14:27 ` Daniel Vetter
2014-09-08 13:03 ` Tomi Valkeinen
2014-09-08 13:31 ` Daniel Vetter
2014-09-09 7:07 ` Tomi Valkeinen [this message]
2014-09-09 10:43 ` Rob Clark
2014-09-09 10:54 ` Tomi Valkeinen
2014-09-03 11:55 ` [PATCH 8/9] drm/omap: fix preclose to wait for scheduled work Tomi Valkeinen
2014-09-03 14:32 ` Daniel Vetter
2014-09-08 13:09 ` Tomi Valkeinen
2014-09-03 11:55 ` [PATCH 9/9] drm/omap: add a comment why locking is missing Tomi Valkeinen
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=540EA742.3080109@ti.com \
--to=tomi.valkeinen@ti.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.