drm: Move vbl_lock initialization to the right place
authorFrançois Tigeot <ftigeot@wolfpond.org>
Sun, 18 Jan 2015 08:00:07 +0000 (09:00 +0100)
committerFrançois Tigeot <ftigeot@wolfpond.org>
Sun, 18 Jan 2015 08:01:49 +0000 (09:01 +0100)
Reducing differences with Linux 3.9.11

sys/dev/drm/drm_drv.c
sys/dev/drm/drm_irq.c

index 672dbed..110aedf 100644 (file)
@@ -305,7 +305,6 @@ int drm_attach(device_t kdev, drm_pci_id_list_t *idlist)
 
        lockinit(&dev->dev_lock, "drmdev", 0, LK_CANRECURSE);
        lwkt_serialize_init(&dev->irq_lock);
-       lockinit(&dev->vbl_lock, "drmvbl", 0, LK_CANRECURSE);
        lockinit(&dev->event_lock, "drmev", 0, LK_CANRECURSE);
        lockinit(&dev->struct_mutex, "drmslk", 0, LK_CANRECURSE);
 
index a037afc..1253e6e 100644 (file)
@@ -198,10 +198,11 @@ EXPORT_SYMBOL(drm_vblank_cleanup);
 
 int drm_vblank_init(struct drm_device *dev, int num_crtcs)
 {
-       int i;
+       int i, ret = -ENOMEM;
 
        setup_timer(&dev->vblank_disable_timer, vblank_disable_fn,
                    (unsigned long)dev);
+       lockinit(&dev->vbl_lock, "drmvbl", 0, LK_CANRECURSE);
        lockinit(&dev->vblank_time_lock, "drmvtl", 0, LK_CANRECURSE);
 
        dev->num_crtcs = num_crtcs;
@@ -221,8 +222,12 @@ int drm_vblank_init(struct drm_device *dev, int num_crtcs)
            M_DRM, M_WAITOK | M_ZERO);
        dev->vblank_inmodeset = kmalloc(num_crtcs * sizeof(int),
            M_DRM, M_WAITOK | M_ZERO);
+
        dev->_vblank_time = kmalloc(num_crtcs * DRM_VBLANKTIME_RBSIZE *
            sizeof(struct timeval), M_DRM, M_WAITOK | M_ZERO);
+       if (!dev->_vblank_time)
+               goto err;
+
        DRM_INFO("Supports vblank timestamp caching Rev 1 (10.10.2010).\n");
 
        /* Driver specific high-precision vblank timestamping supported? */
@@ -240,6 +245,10 @@ int drm_vblank_init(struct drm_device *dev, int num_crtcs)
 
        dev->vblank_disable_allowed = 0;
        return 0;
+
+err:
+       drm_vblank_cleanup(dev);
+       return ret;
 }
 EXPORT_SYMBOL(drm_vblank_init);