Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
Sinclair Yeh | 54fbde8 | 2015-07-29 12:38:02 -0700 | [diff] [blame] | 3 | * Copyright © 2009-2015 VMware, Inc., Palo Alto, CA., USA |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 4 | * All Rights Reserved. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the |
| 8 | * "Software"), to deal in the Software without restriction, including |
| 9 | * without limitation the rights to use, copy, modify, merge, publish, |
| 10 | * distribute, sub license, and/or sell copies of the Software, and to |
| 11 | * permit persons to whom the Software is furnished to do so, subject to |
| 12 | * the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice (including the |
| 15 | * next paragraph) shall be included in all copies or substantial portions |
| 16 | * of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
| 21 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
| 22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 25 | * |
| 26 | **************************************************************************/ |
| 27 | |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 28 | #include <drm/drmP.h> |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 29 | #include "vmwgfx_drv.h" |
| 30 | |
| 31 | #define VMW_FENCE_WRAP (1 << 24) |
| 32 | |
Daniel Vetter | e9f0d76 | 2013-12-11 11:34:42 +0100 | [diff] [blame] | 33 | irqreturn_t vmw_irq_handler(int irq, void *arg) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 34 | { |
| 35 | struct drm_device *dev = (struct drm_device *)arg; |
| 36 | struct vmw_private *dev_priv = vmw_priv(dev); |
Thomas Hellstrom | 57c5ee7 | 2011-10-10 12:23:26 +0200 | [diff] [blame] | 37 | uint32_t status, masked_status; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 38 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 39 | status = inl(dev_priv->io_start + VMWGFX_IRQSTATUS_PORT); |
Thomas Hellstrom | d2e8851 | 2015-10-28 19:07:35 +0100 | [diff] [blame] | 40 | masked_status = status & READ_ONCE(dev_priv->irq_mask); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 41 | |
Thomas Hellstrom | 57c5ee7 | 2011-10-10 12:23:26 +0200 | [diff] [blame] | 42 | if (likely(status)) |
| 43 | outl(status, dev_priv->io_start + VMWGFX_IRQSTATUS_PORT); |
Thomas Hellstrom | ae2a104 | 2011-09-01 20:18:44 +0000 | [diff] [blame] | 44 | |
Thomas Hellstrom | d2e8851 | 2015-10-28 19:07:35 +0100 | [diff] [blame] | 45 | if (!status) |
Thomas Hellstrom | 57c5ee7 | 2011-10-10 12:23:26 +0200 | [diff] [blame] | 46 | return IRQ_NONE; |
| 47 | |
| 48 | if (masked_status & (SVGA_IRQFLAG_ANY_FENCE | |
| 49 | SVGA_IRQFLAG_FENCE_GOAL)) { |
| 50 | vmw_fences_update(dev_priv->fman); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 51 | wake_up_all(&dev_priv->fence_queue); |
Thomas Hellstrom | ae2a104 | 2011-09-01 20:18:44 +0000 | [diff] [blame] | 52 | } |
Thomas Hellstrom | 57c5ee7 | 2011-10-10 12:23:26 +0200 | [diff] [blame] | 53 | |
| 54 | if (masked_status & SVGA_IRQFLAG_FIFO_PROGRESS) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 55 | wake_up_all(&dev_priv->fifo_queue); |
| 56 | |
Thomas Hellstrom | 3eab3d9 | 2015-06-25 11:57:56 -0700 | [diff] [blame] | 57 | if (masked_status & (SVGA_IRQFLAG_COMMAND_BUFFER | |
| 58 | SVGA_IRQFLAG_ERROR)) |
| 59 | vmw_cmdbuf_tasklet_schedule(dev_priv->cman); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 60 | |
Thomas Hellstrom | 57c5ee7 | 2011-10-10 12:23:26 +0200 | [diff] [blame] | 61 | return IRQ_HANDLED; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 62 | } |
| 63 | |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 64 | static bool vmw_fifo_idle(struct vmw_private *dev_priv, uint32_t seqno) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 65 | { |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 66 | |
Thomas Hellstrom | 496eb6f | 2015-01-14 02:33:39 -0800 | [diff] [blame] | 67 | return (vmw_read(dev_priv, SVGA_REG_BUSY) == 0); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 68 | } |
| 69 | |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 70 | void vmw_update_seqno(struct vmw_private *dev_priv, |
Thomas Hellstrom | 1925d45 | 2010-05-28 11:21:57 +0200 | [diff] [blame] | 71 | struct vmw_fifo_state *fifo_state) |
| 72 | { |
Thomas Hellstrom | b76ff5e | 2015-10-28 10:44:04 +0100 | [diff] [blame] | 73 | u32 *fifo_mem = dev_priv->mmio_virt; |
| 74 | uint32_t seqno = vmw_mmio_read(fifo_mem + SVGA_FIFO_FENCE); |
Thomas Hellstrom | 1925d45 | 2010-05-28 11:21:57 +0200 | [diff] [blame] | 75 | |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 76 | if (dev_priv->last_read_seqno != seqno) { |
| 77 | dev_priv->last_read_seqno = seqno; |
| 78 | vmw_marker_pull(&fifo_state->marker_queue, seqno); |
Thomas Hellstrom | 57c5ee7 | 2011-10-10 12:23:26 +0200 | [diff] [blame] | 79 | vmw_fences_update(dev_priv->fman); |
Thomas Hellstrom | 1925d45 | 2010-05-28 11:21:57 +0200 | [diff] [blame] | 80 | } |
| 81 | } |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 82 | |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 83 | bool vmw_seqno_passed(struct vmw_private *dev_priv, |
| 84 | uint32_t seqno) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 85 | { |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 86 | struct vmw_fifo_state *fifo_state; |
| 87 | bool ret; |
| 88 | |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 89 | if (likely(dev_priv->last_read_seqno - seqno < VMW_FENCE_WRAP)) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 90 | return true; |
| 91 | |
Thomas Hellstrom | 1925d45 | 2010-05-28 11:21:57 +0200 | [diff] [blame] | 92 | fifo_state = &dev_priv->fifo; |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 93 | vmw_update_seqno(dev_priv, fifo_state); |
| 94 | if (likely(dev_priv->last_read_seqno - seqno < VMW_FENCE_WRAP)) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 95 | return true; |
| 96 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 97 | if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE) && |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 98 | vmw_fifo_idle(dev_priv, seqno)) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 99 | return true; |
| 100 | |
| 101 | /** |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 102 | * Then check if the seqno is higher than what we've actually |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 103 | * emitted. Then the fence is stale and signaled. |
| 104 | */ |
| 105 | |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 106 | ret = ((atomic_read(&dev_priv->marker_seq) - seqno) |
Thomas Hellstrom | 85b9e48 | 2010-02-08 09:57:25 +0000 | [diff] [blame] | 107 | > VMW_FENCE_WRAP); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 108 | |
| 109 | return ret; |
| 110 | } |
| 111 | |
| 112 | int vmw_fallback_wait(struct vmw_private *dev_priv, |
| 113 | bool lazy, |
| 114 | bool fifo_idle, |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 115 | uint32_t seqno, |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 116 | bool interruptible, |
| 117 | unsigned long timeout) |
| 118 | { |
| 119 | struct vmw_fifo_state *fifo_state = &dev_priv->fifo; |
| 120 | |
| 121 | uint32_t count = 0; |
| 122 | uint32_t signal_seq; |
| 123 | int ret; |
| 124 | unsigned long end_jiffies = jiffies + timeout; |
| 125 | bool (*wait_condition)(struct vmw_private *, uint32_t); |
| 126 | DEFINE_WAIT(__wait); |
| 127 | |
| 128 | wait_condition = (fifo_idle) ? &vmw_fifo_idle : |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 129 | &vmw_seqno_passed; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 130 | |
| 131 | /** |
| 132 | * Block command submission while waiting for idle. |
| 133 | */ |
| 134 | |
Thomas Hellstrom | 3eab3d9 | 2015-06-25 11:57:56 -0700 | [diff] [blame] | 135 | if (fifo_idle) { |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 136 | down_read(&fifo_state->rwsem); |
Thomas Hellstrom | 3eab3d9 | 2015-06-25 11:57:56 -0700 | [diff] [blame] | 137 | if (dev_priv->cman) { |
| 138 | ret = vmw_cmdbuf_idle(dev_priv->cman, interruptible, |
| 139 | 10*HZ); |
| 140 | if (ret) |
| 141 | goto out_err; |
| 142 | } |
| 143 | } |
| 144 | |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 145 | signal_seq = atomic_read(&dev_priv->marker_seq); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 146 | ret = 0; |
| 147 | |
| 148 | for (;;) { |
| 149 | prepare_to_wait(&dev_priv->fence_queue, &__wait, |
| 150 | (interruptible) ? |
| 151 | TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 152 | if (wait_condition(dev_priv, seqno)) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 153 | break; |
| 154 | if (time_after_eq(jiffies, end_jiffies)) { |
| 155 | DRM_ERROR("SVGA device lockup.\n"); |
| 156 | break; |
| 157 | } |
| 158 | if (lazy) |
| 159 | schedule_timeout(1); |
| 160 | else if ((++count & 0x0F) == 0) { |
| 161 | /** |
| 162 | * FIXME: Use schedule_hr_timeout here for |
| 163 | * newer kernels and lower CPU utilization. |
| 164 | */ |
| 165 | |
| 166 | __set_current_state(TASK_RUNNING); |
| 167 | schedule(); |
| 168 | __set_current_state((interruptible) ? |
| 169 | TASK_INTERRUPTIBLE : |
| 170 | TASK_UNINTERRUPTIBLE); |
| 171 | } |
| 172 | if (interruptible && signal_pending(current)) { |
Thomas Hellstrom | 3d3a5b3 | 2009-12-08 12:59:34 +0100 | [diff] [blame] | 173 | ret = -ERESTARTSYS; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 174 | break; |
| 175 | } |
| 176 | } |
| 177 | finish_wait(&dev_priv->fence_queue, &__wait); |
| 178 | if (ret == 0 && fifo_idle) { |
Thomas Hellstrom | b76ff5e | 2015-10-28 10:44:04 +0100 | [diff] [blame] | 179 | u32 *fifo_mem = dev_priv->mmio_virt; |
| 180 | |
| 181 | vmw_mmio_write(signal_seq, fifo_mem + SVGA_FIFO_FENCE); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 182 | } |
| 183 | wake_up_all(&dev_priv->fence_queue); |
Thomas Hellstrom | 3eab3d9 | 2015-06-25 11:57:56 -0700 | [diff] [blame] | 184 | out_err: |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 185 | if (fifo_idle) |
| 186 | up_read(&fifo_state->rwsem); |
| 187 | |
| 188 | return ret; |
| 189 | } |
| 190 | |
Thomas Hellstrom | d2e8851 | 2015-10-28 19:07:35 +0100 | [diff] [blame] | 191 | void vmw_generic_waiter_add(struct vmw_private *dev_priv, |
| 192 | u32 flag, int *waiter_count) |
| 193 | { |
| 194 | spin_lock_bh(&dev_priv->waiter_lock); |
| 195 | if ((*waiter_count)++ == 0) { |
| 196 | outl(flag, dev_priv->io_start + VMWGFX_IRQSTATUS_PORT); |
| 197 | dev_priv->irq_mask |= flag; |
| 198 | vmw_write(dev_priv, SVGA_REG_IRQMASK, dev_priv->irq_mask); |
| 199 | } |
| 200 | spin_unlock_bh(&dev_priv->waiter_lock); |
| 201 | } |
| 202 | |
| 203 | void vmw_generic_waiter_remove(struct vmw_private *dev_priv, |
| 204 | u32 flag, int *waiter_count) |
| 205 | { |
| 206 | spin_lock_bh(&dev_priv->waiter_lock); |
| 207 | if (--(*waiter_count) == 0) { |
| 208 | dev_priv->irq_mask &= ~flag; |
| 209 | vmw_write(dev_priv, SVGA_REG_IRQMASK, dev_priv->irq_mask); |
| 210 | } |
| 211 | spin_unlock_bh(&dev_priv->waiter_lock); |
| 212 | } |
| 213 | |
Thomas Hellstrom | ae2a104 | 2011-09-01 20:18:44 +0000 | [diff] [blame] | 214 | void vmw_seqno_waiter_add(struct vmw_private *dev_priv) |
Thomas Hellstrom | 4f73a96 | 2011-09-01 20:18:43 +0000 | [diff] [blame] | 215 | { |
Thomas Hellstrom | d2e8851 | 2015-10-28 19:07:35 +0100 | [diff] [blame] | 216 | vmw_generic_waiter_add(dev_priv, SVGA_IRQFLAG_ANY_FENCE, |
| 217 | &dev_priv->fence_queue_waiters); |
Thomas Hellstrom | 4f73a96 | 2011-09-01 20:18:43 +0000 | [diff] [blame] | 218 | } |
| 219 | |
Thomas Hellstrom | ae2a104 | 2011-09-01 20:18:44 +0000 | [diff] [blame] | 220 | void vmw_seqno_waiter_remove(struct vmw_private *dev_priv) |
Thomas Hellstrom | 4f73a96 | 2011-09-01 20:18:43 +0000 | [diff] [blame] | 221 | { |
Thomas Hellstrom | d2e8851 | 2015-10-28 19:07:35 +0100 | [diff] [blame] | 222 | vmw_generic_waiter_remove(dev_priv, SVGA_IRQFLAG_ANY_FENCE, |
| 223 | &dev_priv->fence_queue_waiters); |
Thomas Hellstrom | 57c5ee7 | 2011-10-10 12:23:26 +0200 | [diff] [blame] | 224 | } |
| 225 | |
Thomas Hellstrom | 57c5ee7 | 2011-10-10 12:23:26 +0200 | [diff] [blame] | 226 | void vmw_goal_waiter_add(struct vmw_private *dev_priv) |
| 227 | { |
Thomas Hellstrom | d2e8851 | 2015-10-28 19:07:35 +0100 | [diff] [blame] | 228 | vmw_generic_waiter_add(dev_priv, SVGA_IRQFLAG_FENCE_GOAL, |
| 229 | &dev_priv->goal_queue_waiters); |
Thomas Hellstrom | 57c5ee7 | 2011-10-10 12:23:26 +0200 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | void vmw_goal_waiter_remove(struct vmw_private *dev_priv) |
| 233 | { |
Thomas Hellstrom | d2e8851 | 2015-10-28 19:07:35 +0100 | [diff] [blame] | 234 | vmw_generic_waiter_remove(dev_priv, SVGA_IRQFLAG_FENCE_GOAL, |
| 235 | &dev_priv->goal_queue_waiters); |
Thomas Hellstrom | 4f73a96 | 2011-09-01 20:18:43 +0000 | [diff] [blame] | 236 | } |
| 237 | |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 238 | int vmw_wait_seqno(struct vmw_private *dev_priv, |
| 239 | bool lazy, uint32_t seqno, |
| 240 | bool interruptible, unsigned long timeout) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 241 | { |
| 242 | long ret; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 243 | struct vmw_fifo_state *fifo = &dev_priv->fifo; |
| 244 | |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 245 | if (likely(dev_priv->last_read_seqno - seqno < VMW_FENCE_WRAP)) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 246 | return 0; |
| 247 | |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 248 | if (likely(vmw_seqno_passed(dev_priv, seqno))) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 249 | return 0; |
| 250 | |
| 251 | vmw_fifo_ping_host(dev_priv, SVGA_SYNC_GENERIC); |
| 252 | |
| 253 | if (!(fifo->capabilities & SVGA_FIFO_CAP_FENCE)) |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 254 | return vmw_fallback_wait(dev_priv, lazy, true, seqno, |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 255 | interruptible, timeout); |
| 256 | |
| 257 | if (!(dev_priv->capabilities & SVGA_CAP_IRQMASK)) |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 258 | return vmw_fallback_wait(dev_priv, lazy, false, seqno, |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 259 | interruptible, timeout); |
| 260 | |
Thomas Hellstrom | 4f73a96 | 2011-09-01 20:18:43 +0000 | [diff] [blame] | 261 | vmw_seqno_waiter_add(dev_priv); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 262 | |
| 263 | if (interruptible) |
| 264 | ret = wait_event_interruptible_timeout |
| 265 | (dev_priv->fence_queue, |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 266 | vmw_seqno_passed(dev_priv, seqno), |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 267 | timeout); |
| 268 | else |
| 269 | ret = wait_event_timeout |
| 270 | (dev_priv->fence_queue, |
Thomas Hellstrom | 6bcd8d3c | 2011-09-01 20:18:42 +0000 | [diff] [blame] | 271 | vmw_seqno_passed(dev_priv, seqno), |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 272 | timeout); |
| 273 | |
Thomas Hellstrom | 4f73a96 | 2011-09-01 20:18:43 +0000 | [diff] [blame] | 274 | vmw_seqno_waiter_remove(dev_priv); |
| 275 | |
Thomas Hellstrom | 3d3a5b3 | 2009-12-08 12:59:34 +0100 | [diff] [blame] | 276 | if (unlikely(ret == 0)) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 277 | ret = -EBUSY; |
| 278 | else if (likely(ret > 0)) |
| 279 | ret = 0; |
| 280 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 281 | return ret; |
| 282 | } |
| 283 | |
| 284 | void vmw_irq_preinstall(struct drm_device *dev) |
| 285 | { |
| 286 | struct vmw_private *dev_priv = vmw_priv(dev); |
| 287 | uint32_t status; |
| 288 | |
| 289 | if (!(dev_priv->capabilities & SVGA_CAP_IRQMASK)) |
| 290 | return; |
| 291 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 292 | status = inl(dev_priv->io_start + VMWGFX_IRQSTATUS_PORT); |
| 293 | outl(status, dev_priv->io_start + VMWGFX_IRQSTATUS_PORT); |
| 294 | } |
| 295 | |
| 296 | int vmw_irq_postinstall(struct drm_device *dev) |
| 297 | { |
| 298 | return 0; |
| 299 | } |
| 300 | |
| 301 | void vmw_irq_uninstall(struct drm_device *dev) |
| 302 | { |
| 303 | struct vmw_private *dev_priv = vmw_priv(dev); |
| 304 | uint32_t status; |
| 305 | |
| 306 | if (!(dev_priv->capabilities & SVGA_CAP_IRQMASK)) |
| 307 | return; |
| 308 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 309 | vmw_write(dev_priv, SVGA_REG_IRQMASK, 0); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 310 | |
| 311 | status = inl(dev_priv->io_start + VMWGFX_IRQSTATUS_PORT); |
| 312 | outl(status, dev_priv->io_start + VMWGFX_IRQSTATUS_PORT); |
| 313 | } |