From 957b10695b619d6ed2f1098b00502395d9a3c149 Mon Sep 17 00:00:00 2001 From: Robert Noland Date: Wed, 25 Feb 2009 17:59:26 -0600 Subject: [PATCH] Move vblank_init to driver load time. --- bsd-core/drmP.h | 1 + bsd-core/drm_drv.c | 2 ++ bsd-core/drm_irq.c | 4 +--- bsd-core/mach64_drv.c | 7 +++++++ bsd-core/r128_drv.c | 6 ++++++ linux-core/drm_drv.c | 2 ++ linux-core/drm_irq.c | 4 +--- shared-core/i915_dma.c | 7 +++++++ shared-core/i915_drv.h | 2 ++ shared-core/i915_irq.c | 5 ----- shared-core/mach64_drv.h | 1 + shared-core/mach64_irq.c | 2 +- shared-core/mga_dma.c | 8 ++++++++ shared-core/mga_irq.c | 5 ----- shared-core/r128_drv.h | 1 + shared-core/r128_irq.c | 2 +- shared-core/radeon_cp.c | 6 ++++++ shared-core/radeon_irq.c | 5 ----- shared-core/via_irq.c | 1 - shared-core/via_map.c | 12 +++++++++++- 20 files changed, 58 insertions(+), 25 deletions(-) diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h index 573c2b1..69147b3 100644 --- a/bsd-core/drmP.h +++ b/bsd-core/drmP.h @@ -797,6 +797,7 @@ void drm_handle_vblank(struct drm_device *dev, int crtc); u32 drm_vblank_count(struct drm_device *dev, int crtc); int drm_vblank_get(struct drm_device *dev, int crtc); void drm_vblank_put(struct drm_device *dev, int crtc); +void drm_vblank_cleanup(struct drm_device *dev); int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); int drm_vblank_init(struct drm_device *dev, int num_crtcs); void drm_vbl_send_signals(struct drm_device *dev, int crtc); diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c index c45a442..794f32e 100644 --- a/bsd-core/drm_drv.c +++ b/bsd-core/drm_drv.c @@ -512,6 +512,8 @@ static void drm_unload(struct drm_device *dev) DRM_DEBUG("mtrr_del = %d", retcode); } + drm_vblank_cleanup(dev); + DRM_LOCK(); drm_lastclose(dev); DRM_UNLOCK(); diff --git a/bsd-core/drm_irq.c b/bsd-core/drm_irq.c index 8a9d344..2ca4275 100644 --- a/bsd-core/drm_irq.c +++ b/bsd-core/drm_irq.c @@ -93,7 +93,7 @@ static void vblank_disable_fn(void *arg) } } -static void drm_vblank_cleanup(struct drm_device *dev) +void drm_vblank_cleanup(struct drm_device *dev) { unsigned long irqflags; @@ -210,8 +210,6 @@ int drm_irq_uninstall(struct drm_device *dev) bus_teardown_intr(dev->device, dev->irqr, dev->irqh); DRM_LOCK(); - drm_vblank_cleanup(dev); - return 0; } diff --git a/bsd-core/mach64_drv.c b/bsd-core/mach64_drv.c index 1cbe5f3..f73e773 100644 --- a/bsd-core/mach64_drv.c +++ b/bsd-core/mach64_drv.c @@ -51,6 +51,7 @@ static void mach64_configure(struct drm_device *dev) DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ; dev->driver->buf_priv_size = 1; /* No dev_priv */ + dev->driver->load = mach64_driver_load; dev->driver->lastclose = mach64_driver_lastclose; dev->driver->get_vblank_counter = mach64_get_vblank_counter; dev->driver->enable_vblank = mach64_enable_vblank; @@ -91,6 +92,12 @@ mach64_attach(device_t nbdev) return drm_attach(nbdev, mach64_pciidlist); } +int +mach64_driver_load(struct drm_device * dev, unsigned long flags) +{ + return drm_vblank_init(dev, 1); +} + static int mach64_detach(device_t nbdev) { diff --git a/bsd-core/r128_drv.c b/bsd-core/r128_drv.c index 3dbf66e..f28bcf2 100644 --- a/bsd-core/r128_drv.c +++ b/bsd-core/r128_drv.c @@ -49,6 +49,7 @@ static void r128_configure(struct drm_device *dev) DRIVER_SG | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ; dev->driver->buf_priv_size = sizeof(drm_r128_buf_priv_t); + dev->driver->load = r128_driver_load; dev->driver->preclose = r128_driver_preclose; dev->driver->lastclose = r128_driver_lastclose; dev->driver->get_vblank_counter = r128_get_vblank_counter; @@ -90,6 +91,11 @@ r128_attach(device_t nbdev) return drm_attach(nbdev, r128_pciidlist); } +int r128_driver_load(struct drm_device * dev, unsigned long flags) +{ + return drm_vblank_init(dev, 1); +} + static int r128_detach(device_t nbdev) { diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index 31a98fe..a32bfa3 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -397,6 +397,8 @@ static void drm_cleanup(struct drm_device * dev) return; } + drm_vblank_cleanup(dev); + drm_lastclose(dev); drm_fence_manager_takedown(dev); diff --git a/linux-core/drm_irq.c b/linux-core/drm_irq.c index 57419ca..64fffd9 100644 --- a/linux-core/drm_irq.c +++ b/linux-core/drm_irq.c @@ -94,7 +94,7 @@ static void vblank_disable_fn(unsigned long arg) } } -static void drm_vblank_cleanup(struct drm_device *dev) +void drm_vblank_cleanup(struct drm_device *dev) { /* Bail if the driver didn't call drm_vblank_init() */ if (dev->num_crtcs == 0) @@ -282,8 +282,6 @@ int drm_irq_uninstall(struct drm_device * dev) free_irq(dev->pdev->irq, dev); - drm_vblank_cleanup(dev); - dev->locked_tasklet_func = NULL; return 0; diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c index b97b576..9afb2e8 100644 --- a/shared-core/i915_dma.c +++ b/shared-core/i915_dma.c @@ -898,6 +898,13 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) #endif DRM_SPININIT(&dev_priv->user_irq_lock, "userirq"); + ret = drm_vblank_init(dev, I915_NUM_PIPE); + + if (ret) { + (void) i915_driver_unload(dev); + return ret; + } + return ret; } diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h index aa97aab..6185bcb 100644 --- a/shared-core/i915_drv.h +++ b/shared-core/i915_drv.h @@ -46,6 +46,8 @@ enum pipe { PIPE_B, }; +#define I915_NUM_PIPE 2 + /* Interface history: * * 1.1: Original. diff --git a/shared-core/i915_irq.c b/shared-core/i915_irq.c index 50ff93a..51c1a97 100644 --- a/shared-core/i915_irq.c +++ b/shared-core/i915_irq.c @@ -481,11 +481,6 @@ void i915_driver_irq_preinstall(struct drm_device * dev) int i915_driver_irq_postinstall(struct drm_device *dev) { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; - int ret, num_pipes = 2; - - ret = drm_vblank_init(dev, num_pipes); - if (ret) - return ret; dev_priv->vblank_pipe = DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B; diff --git a/shared-core/mach64_drv.h b/shared-core/mach64_drv.h index fb8a772..6b0020e 100644 --- a/shared-core/mach64_drv.h +++ b/shared-core/mach64_drv.h @@ -163,6 +163,7 @@ extern int mach64_dma_blit(struct drm_device *dev, void *data, extern int mach64_get_param(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int mach64_driver_load(struct drm_device * dev, unsigned long flags); extern u32 mach64_get_vblank_counter(struct drm_device *dev, int crtc); extern int mach64_enable_vblank(struct drm_device *dev, int crtc); extern void mach64_disable_vblank(struct drm_device *dev, int crtc); diff --git a/shared-core/mach64_irq.c b/shared-core/mach64_irq.c index 57879e8..149d970 100644 --- a/shared-core/mach64_irq.c +++ b/shared-core/mach64_irq.c @@ -143,7 +143,7 @@ void mach64_driver_irq_preinstall(struct drm_device * dev) int mach64_driver_irq_postinstall(struct drm_device * dev) { - return drm_vblank_init(dev, 1); + return 0; } void mach64_driver_irq_uninstall(struct drm_device * dev) diff --git a/shared-core/mga_dma.c b/shared-core/mga_dma.c index d56f4d7..dab9403 100644 --- a/shared-core/mga_dma.c +++ b/shared-core/mga_dma.c @@ -396,6 +396,7 @@ int mga_freelist_put(struct drm_device * dev, struct drm_buf * buf) int mga_driver_load(struct drm_device *dev, unsigned long flags) { drm_mga_private_t *dev_priv; + int ret; dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER); if (!dev_priv) @@ -415,6 +416,13 @@ int mga_driver_load(struct drm_device *dev, unsigned long flags) dev->types[7] = _DRM_STAT_PRIMARY; dev->types[8] = _DRM_STAT_SECONDARY; + ret = drm_vblank_init(dev, 1); + + if (ret) { + (void) mga_driver_unload(dev); + return ret; + } + return 0; } diff --git a/shared-core/mga_irq.c b/shared-core/mga_irq.c index 4fe8632..6986ac8 100644 --- a/shared-core/mga_irq.c +++ b/shared-core/mga_irq.c @@ -154,11 +154,6 @@ void mga_driver_irq_preinstall(struct drm_device * dev) int mga_driver_irq_postinstall(struct drm_device * dev) { drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; - int ret; - - ret = drm_vblank_init(dev, 1); - if (ret) - return ret; DRM_INIT_WAITQUEUE(&dev_priv->fence_queue); diff --git a/shared-core/r128_drv.h b/shared-core/r128_drv.h index ab8b629..9e7a646 100644 --- a/shared-core/r128_drv.h +++ b/shared-core/r128_drv.h @@ -159,6 +159,7 @@ extern void r128_driver_irq_preinstall(struct drm_device * dev); extern int r128_driver_irq_postinstall(struct drm_device * dev); extern void r128_driver_irq_uninstall(struct drm_device * dev); extern void r128_driver_lastclose(struct drm_device * dev); +extern int r128_driver_load(struct drm_device * dev, unsigned long flags); extern void r128_driver_preclose(struct drm_device * dev, struct drm_file *file_priv); diff --git a/shared-core/r128_irq.c b/shared-core/r128_irq.c index 5b95bd8..86e5daa 100644 --- a/shared-core/r128_irq.c +++ b/shared-core/r128_irq.c @@ -102,7 +102,7 @@ void r128_driver_irq_preinstall(struct drm_device * dev) int r128_driver_irq_postinstall(struct drm_device * dev) { - return drm_vblank_init(dev, 1); + return 0; } void r128_driver_irq_uninstall(struct drm_device * dev) diff --git a/shared-core/radeon_cp.c b/shared-core/radeon_cp.c index c4035b8..872f589 100644 --- a/shared-core/radeon_cp.c +++ b/shared-core/radeon_cp.c @@ -1748,6 +1748,12 @@ int radeon_driver_load(struct drm_device *dev, unsigned long flags) else dev_priv->flags |= RADEON_IS_PCI; + ret = drm_vblank_init(dev, 2); + if (ret) { + radeon_driver_unload(dev); + return ret; + } + DRM_DEBUG("%s card detected\n", ((dev_priv->flags & RADEON_IS_AGP) ? "AGP" : (((dev_priv->flags & RADEON_IS_PCIE) ? "PCIE" : "PCI")))); return ret; diff --git a/shared-core/radeon_irq.c b/shared-core/radeon_irq.c index 165e7bd..60654b2 100644 --- a/shared-core/radeon_irq.c +++ b/shared-core/radeon_irq.c @@ -369,15 +369,10 @@ int radeon_driver_irq_postinstall(struct drm_device * dev) { drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; - int ret; atomic_set(&dev_priv->swi_emitted, 0); DRM_INIT_WAITQUEUE(&dev_priv->swi_queue); - ret = drm_vblank_init(dev, 2); - if (ret) - return ret; - dev->max_vblank_count = 0x001fffff; radeon_irq_set_state(dev, RADEON_SW_INT_ENABLE, 1); diff --git a/shared-core/via_irq.c b/shared-core/via_irq.c index c3279f8..34e3076 100644 --- a/shared-core/via_irq.c +++ b/shared-core/via_irq.c @@ -320,7 +320,6 @@ int via_driver_irq_postinstall(struct drm_device * dev) if (!dev_priv) return -EINVAL; - drm_vblank_init(dev, 1); status = VIA_READ(VIA_REG_INTERRUPT); VIA_WRITE(VIA_REG_INTERRUPT, status | VIA_IRQ_GLOBAL | dev_priv->irq_enable_mask); diff --git a/shared-core/via_map.c b/shared-core/via_map.c index 5493436..5dee6a7 100644 --- a/shared-core/via_map.c +++ b/shared-core/via_map.c @@ -121,9 +121,19 @@ int via_driver_load(struct drm_device *dev, unsigned long chipset) ret = drm_sman_init(&dev_priv->sman, 2, 12, 8); if (ret) { drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); + return ret; } #endif - return ret; + + ret = drm_vblank_init(dev, 1); + if (ret) { + drm_sman_takedown(&dev_priv->sman); + drm_free(dev_priv, sizeof(drm_via_private_t), DRM_MEM_DRIVER); + return ret; + } + + return 0; + } int via_driver_unload(struct drm_device *dev) -- 2.7.4