From owner-svn-src-head@FreeBSD.ORG Sat Feb 28 02:37:58 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 276341065672; Sat, 28 Feb 2009 02:37:58 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 144B98FC0C; Sat, 28 Feb 2009 02:37:58 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1S2buGb091697; Sat, 28 Feb 2009 02:37:56 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1S2buni091681; Sat, 28 Feb 2009 02:37:56 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200902280237.n1S2buni091681@svn.freebsd.org> From: Robert Noland Date: Sat, 28 Feb 2009 02:37:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189130 - head/sys/dev/drm X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Feb 2009 02:37:58 -0000 Author: rnoland Date: Sat Feb 28 02:37:55 2009 New Revision: 189130 URL: http://svn.freebsd.org/changeset/base/189130 Log: Initialize the vblank structures at load time. Previously we did this at irq install/uninstall time, but when we vt switch, we uninstall the irq handler. When the irq handler is reinstalled, the modeset ioctl happens first. The modeset ioctl is supposed to tell us that we can disable vblank interrupts if there are no active consumers. This will fail after a vt switch until another modeset ioctl is called via dpms or xrandr. Leading to cases where either interrupts are on and can't be disabled, or worse, no interrupts at all. MFC after: 2 weeks Modified: head/sys/dev/drm/drmP.h head/sys/dev/drm/drm_drv.c head/sys/dev/drm/drm_irq.c head/sys/dev/drm/i915_dma.c head/sys/dev/drm/i915_drv.h head/sys/dev/drm/i915_irq.c head/sys/dev/drm/mach64_drv.c head/sys/dev/drm/mach64_drv.h head/sys/dev/drm/mach64_irq.c head/sys/dev/drm/mga_dma.c head/sys/dev/drm/mga_irq.c head/sys/dev/drm/r128_drv.c head/sys/dev/drm/r128_drv.h head/sys/dev/drm/r128_irq.c head/sys/dev/drm/radeon_cp.c head/sys/dev/drm/radeon_irq.c Modified: head/sys/dev/drm/drmP.h ============================================================================== --- head/sys/dev/drm/drmP.h Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/drmP.h Sat Feb 28 02:37:55 2009 (r189130) @@ -794,6 +794,7 @@ void drm_handle_vblank(struct drm_device 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); Modified: head/sys/dev/drm/drm_drv.c ============================================================================== --- head/sys/dev/drm/drm_drv.c Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/drm_drv.c Sat Feb 28 02:37:55 2009 (r189130) @@ -523,6 +523,8 @@ static void drm_unload(struct drm_device DRM_DEBUG("mtrr_del = %d", retcode); } + drm_vblank_cleanup(dev); + DRM_LOCK(); drm_lastclose(dev); DRM_UNLOCK(); Modified: head/sys/dev/drm/drm_irq.c ============================================================================== --- head/sys/dev/drm/drm_irq.c Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/drm_irq.c Sat Feb 28 02:37:55 2009 (r189130) @@ -96,7 +96,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; @@ -213,8 +213,6 @@ int drm_irq_uninstall(struct drm_device bus_teardown_intr(dev->device, dev->irqr, dev->irqh); DRM_LOCK(); - drm_vblank_cleanup(dev); - return 0; } Modified: head/sys/dev/drm/i915_dma.c ============================================================================== --- head/sys/dev/drm/i915_dma.c Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/i915_dma.c Sat Feb 28 02:37:55 2009 (r189130) @@ -902,6 +902,13 @@ int i915_driver_load(struct drm_device * #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; } Modified: head/sys/dev/drm/i915_drv.h ============================================================================== --- head/sys/dev/drm/i915_drv.h Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/i915_drv.h Sat Feb 28 02:37:55 2009 (r189130) @@ -49,6 +49,8 @@ enum pipe { PIPE_B, }; +#define I915_NUM_PIPE 2 + /* Interface history: * * 1.1: Original. Modified: head/sys/dev/drm/i915_irq.c ============================================================================== --- head/sys/dev/drm/i915_irq.c Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/i915_irq.c Sat Feb 28 02:37:55 2009 (r189130) @@ -484,11 +484,6 @@ void i915_driver_irq_preinstall(struct d 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; Modified: head/sys/dev/drm/mach64_drv.c ============================================================================== --- head/sys/dev/drm/mach64_drv.c Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/mach64_drv.c Sat Feb 28 02:37:55 2009 (r189130) @@ -54,6 +54,7 @@ static void mach64_configure(struct drm_ 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; @@ -94,6 +95,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) { Modified: head/sys/dev/drm/mach64_drv.h ============================================================================== --- head/sys/dev/drm/mach64_drv.h Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/mach64_drv.h Sat Feb 28 02:37:55 2009 (r189130) @@ -166,6 +166,7 @@ extern int mach64_dma_blit(struct drm_de 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); Modified: head/sys/dev/drm/mach64_irq.c ============================================================================== --- head/sys/dev/drm/mach64_irq.c Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/mach64_irq.c Sat Feb 28 02:37:55 2009 (r189130) @@ -146,7 +146,7 @@ void mach64_driver_irq_preinstall(struct 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) Modified: head/sys/dev/drm/mga_dma.c ============================================================================== --- head/sys/dev/drm/mga_dma.c Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/mga_dma.c Sat Feb 28 02:37:55 2009 (r189130) @@ -399,6 +399,7 @@ int mga_freelist_put(struct drm_device * 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) @@ -418,6 +419,13 @@ int mga_driver_load(struct drm_device *d 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; } Modified: head/sys/dev/drm/mga_irq.c ============================================================================== --- head/sys/dev/drm/mga_irq.c Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/mga_irq.c Sat Feb 28 02:37:55 2009 (r189130) @@ -157,11 +157,6 @@ void mga_driver_irq_preinstall(struct dr 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); Modified: head/sys/dev/drm/r128_drv.c ============================================================================== --- head/sys/dev/drm/r128_drv.c Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/r128_drv.c Sat Feb 28 02:37:55 2009 (r189130) @@ -52,6 +52,7 @@ static void r128_configure(struct drm_de 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; @@ -93,6 +94,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) { Modified: head/sys/dev/drm/r128_drv.h ============================================================================== --- head/sys/dev/drm/r128_drv.h Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/r128_drv.h Sat Feb 28 02:37:55 2009 (r189130) @@ -162,6 +162,7 @@ extern void r128_driver_irq_preinstall(s 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); Modified: head/sys/dev/drm/r128_irq.c ============================================================================== --- head/sys/dev/drm/r128_irq.c Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/r128_irq.c Sat Feb 28 02:37:55 2009 (r189130) @@ -105,7 +105,7 @@ void r128_driver_irq_preinstall(struct d 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) Modified: head/sys/dev/drm/radeon_cp.c ============================================================================== --- head/sys/dev/drm/radeon_cp.c Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/radeon_cp.c Sat Feb 28 02:37:55 2009 (r189130) @@ -1751,6 +1751,12 @@ int radeon_driver_load(struct drm_device 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; Modified: head/sys/dev/drm/radeon_irq.c ============================================================================== --- head/sys/dev/drm/radeon_irq.c Sat Feb 28 01:05:18 2009 (r189129) +++ head/sys/dev/drm/radeon_irq.c Sat Feb 28 02:37:55 2009 (r189130) @@ -372,15 +372,10 @@ int radeon_driver_irq_postinstall(struct { 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);