All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] drm: do not sleep on vblank while holding a mutex
@ 2011-10-31 17:10 Ilija Hadzic
  2011-10-31 21:09 ` Daniel Vetter
  0 siblings, 1 reply; 3+ messages in thread
From: Ilija Hadzic @ 2011-10-31 17:10 UTC (permalink / raw)
  To: airlied, dri-devel

drm_wait_vblank must be DRM_UNLOCKED because otherwise it
will grab the drm_global_mutex and then go to sleep until the vblank
event it is waiting for. That can wreck havoc in the windowing system
because if one process issues this ioctl, it will block all other
processes for the duration of all vblanks between the current and the
one it is waiting for. In some cases it can block the entire windowing
system.

v2: incorporate comments received from Daniel Vetter and
    Michel Daenzer.

v3: after a lengty discussion with Daniel Vetter, it was concluded
    we should not worry about any locking, within drm_wait_vblank
    function so this patch becomes a rather trivial removal
    of drm_global_mutex from drm_wait_vblank

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
---
 drivers/gpu/drm/drm_drv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index dbabcb0..dc0eb0b 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -124,7 +124,7 @@ static struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 	DRM_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 
-	DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank, 0),
+	DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank, DRM_UNLOCKED),
 
 	DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_modeset_ctl, 0),
 
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] drm: do not sleep on vblank while holding a mutex
  2011-10-31 17:10 [PATCH v3] drm: do not sleep on vblank while holding a mutex Ilija Hadzic
@ 2011-10-31 21:09 ` Daniel Vetter
  2011-10-31 21:13   ` Ilija Hadzic
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Vetter @ 2011-10-31 21:09 UTC (permalink / raw)
  To: Ilija Hadzic; +Cc: dri-devel

On Mon, Oct 31, 2011 at 01:10:21PM -0400, Ilija Hadzic wrote:
> drm_wait_vblank must be DRM_UNLOCKED because otherwise it
> will grab the drm_global_mutex and then go to sleep until the vblank
> event it is waiting for. That can wreck havoc in the windowing system
> because if one process issues this ioctl, it will block all other
> processes for the duration of all vblanks between the current and the
> one it is waiting for. In some cases it can block the entire windowing
> system.
> 
> v2: incorporate comments received from Daniel Vetter and
>     Michel Daenzer.
> 
> v3: after a lengty discussion with Daniel Vetter, it was concluded
>     we should not worry about any locking, within drm_wait_vblank
>     function so this patch becomes a rather trivial removal
>     of drm_global_mutex from drm_wait_vblank

That commit message is a bit garbage. What about ...

"... it was concluded that the only think not yet protected with locks and
atomic ops is the write to dev->last_vblank_wait. It's only used in a
debug file in proc, and the current code already employs no correct
locking: the proc file only takes dev->struct_mutex, whereas
drm_wait_vblank implicitly took the drm_global_mutex. Given all this, it's
not worth bothering to try to fix this at this time."

I think it's important to correctly document the conclusion of this
discussion, because we've worried quite a bit about correct locking.

Yours, Daniel
-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] drm: do not sleep on vblank while holding a mutex
  2011-10-31 21:09 ` Daniel Vetter
@ 2011-10-31 21:13   ` Ilija Hadzic
  0 siblings, 0 replies; 3+ messages in thread
From: Ilija Hadzic @ 2011-10-31 21:13 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: dri-devel


OK, v4 coming up and your suggestion will be copied verbatim. Hopefully 
that does it.

This patch is probably going to become a record-holder in comment/code 
lines ratio ;-)

-- Ilija


On Mon, 31 Oct 2011, Daniel Vetter wrote:

> On Mon, Oct 31, 2011 at 01:10:21PM -0400, Ilija Hadzic wrote:
>> drm_wait_vblank must be DRM_UNLOCKED because otherwise it
>> will grab the drm_global_mutex and then go to sleep until the vblank
>> event it is waiting for. That can wreck havoc in the windowing system
>> because if one process issues this ioctl, it will block all other
>> processes for the duration of all vblanks between the current and the
>> one it is waiting for. In some cases it can block the entire windowing
>> system.
>>
>> v2: incorporate comments received from Daniel Vetter and
>>     Michel Daenzer.
>>
>> v3: after a lengty discussion with Daniel Vetter, it was concluded
>>     we should not worry about any locking, within drm_wait_vblank
>>     function so this patch becomes a rather trivial removal
>>     of drm_global_mutex from drm_wait_vblank
>
> That commit message is a bit garbage. What about ...
>
> "... it was concluded that the only think not yet protected with locks and
> atomic ops is the write to dev->last_vblank_wait. It's only used in a
> debug file in proc, and the current code already employs no correct
> locking: the proc file only takes dev->struct_mutex, whereas
> drm_wait_vblank implicitly took the drm_global_mutex. Given all this, it's
> not worth bothering to try to fix this at this time."
>
> I think it's important to correctly document the conclusion of this
> discussion, because we've worried quite a bit about correct locking.
>
> Yours, Daniel
> -- 
> Daniel Vetter
> Mail: daniel@ffwll.ch
> Mobile: +41 (0)79 365 57 48
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-31 21:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-31 17:10 [PATCH v3] drm: do not sleep on vblank while holding a mutex Ilija Hadzic
2011-10-31 21:09 ` Daniel Vetter
2011-10-31 21:13   ` Ilija Hadzic

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.