[PATCH] drm: make sure drm_vblank_init() has been called before touching vbl_lock
Ben Skeggs
bskeggs at redhat.com
Wed Jul 6 16:10:04 PDT 2011
On Wed, 2011-07-06 at 09:38 +0200, Michel Dänzer wrote:
> On Mon, 2011-07-04 at 13:16 +1000, skeggsb at gmail.com wrote:
> > From: Ben Skeggs <bskeggs at redhat.com>
> >
> > Signed-off-by: Ben Skeggs <bskeggs at redhat.com>
> > ---
> > drivers/gpu/drm/drm_irq.c | 15 +++++++++------
> > 1 files changed, 9 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> > index 2022a5c..c3c87a1 100644
> > --- a/drivers/gpu/drm/drm_irq.c
> > +++ b/drivers/gpu/drm/drm_irq.c
> > @@ -397,13 +397,16 @@ int drm_irq_uninstall(struct drm_device *dev)
> > /*
> > * Wake up any waiters so they don't hang.
> > */
> > - spin_lock_irqsave(&dev->vbl_lock, irqflags);
> > - for (i = 0; i < dev->num_crtcs; i++) {
> > - DRM_WAKEUP(&dev->vbl_queue[i]);
> > - dev->vblank_enabled[i] = 0;
> > - dev->last_vblank[i] = dev->driver->get_vblank_counter(dev, i);
> > + if (dev->num_crtcs) {
> > + spin_lock_irqsave(&dev->vbl_lock, irqflags);
> > + for (i = 0; i < dev->num_crtcs; i++) {
> > + DRM_WAKEUP(&dev->vbl_queue[i]);
> > + dev->vblank_enabled[i] = 0;
> > + dev->last_vblank[i] =
> > + dev->driver->get_vblank_counter(dev, i);
> > + }
> > + spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
> > }
> > - spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
> >
> > if (!irq_enabled)
> > return -EINVAL;
>
> Makes sense, but according to commit
> 7a1c2f6c8d8485af5ac6c2a313f6a7162207a4af ('vmwgfx: Enable use of the
> vblank system'), the vblank ioctls will also access uninitialized data
> if drm_vblank_init() hasn't been called. So, is this just for cases
> where drm_irq_uninstall() is called before the driver gets a chance to
> call drm_vblank_init()?
Heh, ouch.
Yes, it was specifically that case I was aiming for however. If
nouveau's running on a board without any outputs, it won't call
drm_vblank_init(), but it *will* call drm_irq_*. Just avoiding lockdep
complaints on module unload.
Ben.
>
>
More information about the dri-devel
mailing list