aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2014-04-30 19:32:21 -0400
committerDave Airlie <airlied@redhat.com>2014-04-30 19:32:21 -0400
commit444c9a08bf787e8236e132fab7eceeb2f065aa4c (patch)
tree52a117f1531f8fcc7f775cacd309d92e64c27a10 /drivers/gpu
parent7e9ab4081e646fc317d0a87929a352f0e5082190 (diff)
parent3c8413951cbd8a2d855740823fc547c97b845f6f (diff)
Merge branch 'drm-init-cleanup' of git://people.freedesktop.org/~danvet/drm into drm-next
Next pull request, this time more of the drm de-midlayering work. The big thing is that his patch series here removes everything from drm_bus except the set_busid callback. Thierry has a few more patches on top of this to make that one optional to. With that we can ditch all the non-pci drm_bus implementations, which Thierry has already done for the fake tegra host1x drm_bus. Reviewed by Thierry, Laurent and David and now also survived some testing on my intel boxes to make sure the irq fumble is fixed correctly ;-) The last minute rebase was just to add the r-b tags from Thierry for the 2 patches I've redone. * 'drm-init-cleanup' of git://people.freedesktop.org/~danvet/drm: drm/<drivers>: don't set driver->dev_priv_size to 0 drm: Remove dev->kdriver drm: remove drm_bus->get_name drm: rip out dev->devname drm: inline drm_pci_set_unique drm: remove bus->get_irq implementations drm: pass the irq explicitly to drm_irq_install drm/irq: Look up the pci irq directly in the drm_control ioctl drm/irq: track the irq installed in drm_irq_install in dev->irq drm: rename dev->count_lock to dev->buf_lock drm: Rip out totally bogus vga_switcheroo->can_switch locking drm: kill drm_bus->bus_type drm: remove drm_dev_to_irq from drivers drm/irq: remove cargo-culted locking from irq_install/uninstall drm/irq: drm_control is a legacy ioctl, so pci devices only drm/pci: fold in irq_by_busid support drm/irq: simplify irq checks in drm_wait_vblank
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/armada/armada_drv.c2
-rw-r--r--drivers/gpu/drm/ast/ast_drv.c1
-rw-r--r--drivers/gpu/drm/drm_bufs.c32
-rw-r--r--drivers/gpu/drm/drm_info.c6
-rw-r--r--drivers/gpu/drm/drm_ioctl.c13
-rw-r--r--drivers/gpu/drm/drm_irq.c105
-rw-r--r--drivers/gpu/drm/drm_pci.c93
-rw-r--r--drivers/gpu/drm/drm_platform.c25
-rw-r--r--drivers/gpu/drm/drm_stub.c7
-rw-r--r--drivers/gpu/drm/drm_usb.c14
-rw-r--r--drivers/gpu/drm/gma500/psb_drv.c2
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c13
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c9
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c7
-rw-r--r--drivers/gpu/drm/mga/mga_state.c2
-rw-r--r--drivers/gpu/drm/msm/msm_drv.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_vga.c11
-rw-r--r--drivers/gpu/drm/qxl/qxl_drv.c1
-rw-r--r--drivers/gpu/drm/qxl/qxl_irq.c2
-rw-r--r--drivers/gpu/drm/r128/r128_state.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c11
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_irq_kms.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_state.c2
-rw-r--r--drivers/gpu/drm/shmobile/shmob_drm_drv.c2
-rw-r--r--drivers/gpu/drm/tegra/bus.c11
-rw-r--r--drivers/gpu/drm/tilcdc/tilcdc_drv.c2
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c2
28 files changed, 149 insertions, 233 deletions
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 32982da82694..567cfbde0883 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -173,7 +173,7 @@ static int armada_drm_load(struct drm_device *dev, unsigned long flags)
173 if (ret) 173 if (ret)
174 goto err_kms; 174 goto err_kms;
175 175
176 ret = drm_irq_install(dev); 176 ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
177 if (ret) 177 if (ret)
178 goto err_kms; 178 goto err_kms;
179 179
diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index 5137f15dba19..2ba39ac7d222 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -198,7 +198,6 @@ static const struct file_operations ast_fops = {
198 198
199static struct drm_driver driver = { 199static struct drm_driver driver = {
200 .driver_features = DRIVER_MODESET | DRIVER_GEM, 200 .driver_features = DRIVER_MODESET | DRIVER_GEM,
201 .dev_priv_size = 0,
202 201
203 .load = ast_driver_load, 202 .load = ast_driver_load,
204 .unload = ast_driver_unload, 203 .unload = ast_driver_unload,
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index edec31fe3fed..ef7f0199a0f1 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -656,13 +656,13 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request)
656 DRM_DEBUG("zone invalid\n"); 656 DRM_DEBUG("zone invalid\n");
657 return -EINVAL; 657 return -EINVAL;
658 } 658 }
659 spin_lock(&dev->count_lock); 659 spin_lock(&dev->buf_lock);
660 if (dev->buf_use) { 660 if (dev->buf_use) {
661 spin_unlock(&dev->count_lock); 661 spin_unlock(&dev->buf_lock);
662 return -EBUSY; 662 return -EBUSY;
663 } 663 }
664 atomic_inc(&dev->buf_alloc); 664 atomic_inc(&dev->buf_alloc);
665 spin_unlock(&dev->count_lock); 665 spin_unlock(&dev->buf_lock);
666 666
667 mutex_lock(&dev->struct_mutex); 667 mutex_lock(&dev->struct_mutex);
668 entry = &dma->bufs[order]; 668 entry = &dma->bufs[order];
@@ -805,13 +805,13 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request)
805 page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; 805 page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
806 total = PAGE_SIZE << page_order; 806 total = PAGE_SIZE << page_order;
807 807
808 spin_lock(&dev->count_lock); 808 spin_lock(&dev->buf_lock);
809 if (dev->buf_use) { 809 if (dev->buf_use) {
810 spin_unlock(&dev->count_lock); 810 spin_unlock(&dev->buf_lock);
811 return -EBUSY; 811 return -EBUSY;
812 } 812 }
813 atomic_inc(&dev->buf_alloc); 813 atomic_inc(&dev->buf_alloc);
814 spin_unlock(&dev->count_lock); 814 spin_unlock(&dev->buf_lock);
815 815
816 mutex_lock(&dev->struct_mutex); 816 mutex_lock(&dev->struct_mutex);
817 entry = &dma->bufs[order]; 817 entry = &dma->bufs[order];
@@ -1015,13 +1015,13 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request
1015 if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) 1015 if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
1016 return -EINVAL; 1016 return -EINVAL;
1017 1017
1018 spin_lock(&dev->count_lock); 1018 spin_lock(&dev->buf_lock);
1019 if (dev->buf_use) { 1019 if (dev->buf_use) {
1020 spin_unlock(&dev->count_lock); 1020 spin_unlock(&dev->buf_lock);
1021 return -EBUSY; 1021 return -EBUSY;
1022 } 1022 }
1023 atomic_inc(&dev->buf_alloc); 1023 atomic_inc(&dev->buf_alloc);
1024 spin_unlock(&dev->count_lock); 1024 spin_unlock(&dev->buf_lock);
1025 1025
1026 mutex_lock(&dev->struct_mutex); 1026 mutex_lock(&dev->struct_mutex);
1027 entry = &dma->bufs[order]; 1027 entry = &dma->bufs[order];
@@ -1175,7 +1175,7 @@ int drm_addbufs(struct drm_device *dev, void *data,
1175 * \param arg pointer to a drm_buf_info structure. 1175 * \param arg pointer to a drm_buf_info structure.
1176 * \return zero on success or a negative number on failure. 1176 * \return zero on success or a negative number on failure.
1177 * 1177 *
1178 * Increments drm_device::buf_use while holding the drm_device::count_lock 1178 * Increments drm_device::buf_use while holding the drm_device::buf_lock
1179 * lock, preventing of allocating more buffers after this call. Information 1179 * lock, preventing of allocating more buffers after this call. Information
1180 * about each requested buffer is then copied into user space. 1180 * about each requested buffer is then copied into user space.
1181 */ 1181 */
@@ -1196,13 +1196,13 @@ int drm_infobufs(struct drm_device *dev, void *data,
1196 if (!dma) 1196 if (!dma)
1197 return -EINVAL; 1197 return -EINVAL;
1198 1198
1199 spin_lock(&dev->count_lock); 1199 spin_lock(&dev->buf_lock);
1200 if (atomic_read(&dev->buf_alloc)) { 1200 if (atomic_read(&dev->buf_alloc)) {
1201 spin_unlock(&dev->count_lock); 1201 spin_unlock(&dev->buf_lock);
1202 return -EBUSY; 1202 return -EBUSY;
1203 } 1203 }
1204 ++dev->buf_use; /* Can't allocate more after this call */ 1204 ++dev->buf_use; /* Can't allocate more after this call */
1205 spin_unlock(&dev->count_lock); 1205 spin_unlock(&dev->buf_lock);
1206 1206
1207 for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) { 1207 for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) {
1208 if (dma->bufs[i].buf_count) 1208 if (dma->bufs[i].buf_count)
@@ -1381,13 +1381,13 @@ int drm_mapbufs(struct drm_device *dev, void *data,
1381 if (!dma) 1381 if (!dma)
1382 return -EINVAL; 1382 return -EINVAL;
1383 1383
1384 spin_lock(&dev->count_lock); 1384 spin_lock(&dev->buf_lock);
1385 if (atomic_read(&dev->buf_alloc)) { 1385 if (atomic_read(&dev->buf_alloc)) {
1386 spin_unlock(&dev->count_lock); 1386 spin_unlock(&dev->buf_lock);
1387 return -EBUSY; 1387 return -EBUSY;
1388 } 1388 }
1389 dev->buf_use++; /* Can't allocate more after this call */ 1389 dev->buf_use++; /* Can't allocate more after this call */
1390 spin_unlock(&dev->count_lock); 1390 spin_unlock(&dev->buf_lock);
1391 1391
1392 if (request->count >= dma->buf_count) { 1392 if (request->count >= dma->buf_count) {
1393 if ((dev->agp && (dma->flags & _DRM_DMA_USE_AGP)) 1393 if ((dev->agp && (dma->flags & _DRM_DMA_USE_AGP))
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index 7473035dd28b..86feedd5e6f6 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -47,18 +47,16 @@ int drm_name_info(struct seq_file *m, void *data)
47 struct drm_minor *minor = node->minor; 47 struct drm_minor *minor = node->minor;
48 struct drm_device *dev = minor->dev; 48 struct drm_device *dev = minor->dev;
49 struct drm_master *master = minor->master; 49 struct drm_master *master = minor->master;
50 const char *bus_name;
51 if (!master) 50 if (!master)
52 return 0; 51 return 0;
53 52
54 bus_name = dev->driver->bus->get_name(dev);
55 if (master->unique) { 53 if (master->unique) {
56 seq_printf(m, "%s %s %s\n", 54 seq_printf(m, "%s %s %s\n",
57 bus_name, 55 dev->driver->name,
58 dev_name(dev->dev), master->unique); 56 dev_name(dev->dev), master->unique);
59 } else { 57 } else {
60 seq_printf(m, "%s %s\n", 58 seq_printf(m, "%s %s\n",
61 bus_name, dev_name(dev->dev)); 59 dev->driver->name, dev_name(dev->dev));
62 } 60 }
63 return 0; 61 return 0;
64} 62}
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 93a42040bedb..38269d5aa333 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -72,9 +72,6 @@ static void
72drm_unset_busid(struct drm_device *dev, 72drm_unset_busid(struct drm_device *dev,
73 struct drm_master *master) 73 struct drm_master *master)
74{ 74{
75 kfree(dev->devname);
76 dev->devname = NULL;
77
78 kfree(master->unique); 75 kfree(master->unique);
79 master->unique = NULL; 76 master->unique = NULL;
80 master->unique_len = 0; 77 master->unique_len = 0;
@@ -93,7 +90,8 @@ drm_unset_busid(struct drm_device *dev,
93 * Copies the bus id from userspace into drm_device::unique, and verifies that 90 * Copies the bus id from userspace into drm_device::unique, and verifies that
94 * it matches the device this DRM is attached to (EINVAL otherwise). Deprecated 91 * it matches the device this DRM is attached to (EINVAL otherwise). Deprecated
95 * in interface version 1.1 and will return EBUSY when setversion has requested 92 * in interface version 1.1 and will return EBUSY when setversion has requested
96 * version 1.1 or greater. 93 * version 1.1 or greater. Also note that KMS is all version 1.1 and later and
94 * UMS was only ever supported on pci devices.
97 */ 95 */
98int drm_setunique(struct drm_device *dev, void *data, 96int drm_setunique(struct drm_device *dev, void *data,
99 struct drm_file *file_priv) 97 struct drm_file *file_priv)
@@ -108,10 +106,13 @@ int drm_setunique(struct drm_device *dev, void *data,
108 if (!u->unique_len || u->unique_len > 1024) 106 if (!u->unique_len || u->unique_len > 1024)
109 return -EINVAL; 107 return -EINVAL;
110 108
111 if (!dev->driver->bus->set_unique) 109 if (drm_core_check_feature(dev, DRIVER_MODESET))
110 return 0;
111
112 if (WARN_ON(!dev->pdev))
112 return -EINVAL; 113 return -EINVAL;
113 114
114 ret = dev->driver->bus->set_unique(dev, master, u); 115 ret = drm_pci_set_unique(dev, master, u);
115 if (ret) 116 if (ret)
116 goto err; 117 goto err;
117 118
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index c2676b5908d9..7583767ec619 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -56,33 +56,6 @@
56 */ 56 */
57#define DRM_REDUNDANT_VBLIRQ_THRESH_NS 1000000 57#define DRM_REDUNDANT_VBLIRQ_THRESH_NS 1000000
58 58
59/**
60 * Get interrupt from bus id.
61 *
62 * \param inode device inode.
63 * \param file_priv DRM file private.
64 * \param cmd command.
65 * \param arg user argument, pointing to a drm_irq_busid structure.
66 * \return zero on success or a negative number on failure.
67 *
68 * Finds the PCI device with the specified bus id and gets its IRQ number.
69 * This IOCTL is deprecated, and will now return EINVAL for any busid not equal
70 * to that of the device that this DRM instance attached to.
71 */
72int drm_irq_by_busid(struct drm_device *dev, void *data,
73 struct drm_file *file_priv)
74{
75 struct drm_irq_busid *p = data;
76
77 if (!dev->driver->bus->irq_by_busid)
78 return -EINVAL;
79
80 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
81 return -EINVAL;
82
83 return dev->driver->bus->irq_by_busid(dev, p);
84}
85
86/* 59/*
87 * Clear vblank timestamp buffer for a crtc. 60 * Clear vblank timestamp buffer for a crtc.
88 */ 61 */
@@ -269,34 +242,26 @@ static void drm_irq_vgaarb_nokms(void *cookie, bool state)
269 * \c irq_preinstall() and \c irq_postinstall() functions 242 * \c irq_preinstall() and \c irq_postinstall() functions
270 * before and after the installation. 243 * before and after the installation.
271 */ 244 */
272int drm_irq_install(struct drm_device *dev) 245int drm_irq_install(struct drm_device *dev, int irq)
273{ 246{
274 int ret; 247 int ret;
275 unsigned long sh_flags = 0; 248 unsigned long sh_flags = 0;
276 char *irqname;
277 249
278 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 250 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
279 return -EINVAL; 251 return -EINVAL;
280 252
281 if (drm_dev_to_irq(dev) == 0) 253 if (irq == 0)
282 return -EINVAL; 254 return -EINVAL;
283 255
284 mutex_lock(&dev->struct_mutex);
285
286 /* Driver must have been initialized */ 256 /* Driver must have been initialized */
287 if (!dev->dev_private) { 257 if (!dev->dev_private)
288 mutex_unlock(&dev->struct_mutex);
289 return -EINVAL; 258 return -EINVAL;
290 }
291 259
292 if (dev->irq_enabled) { 260 if (dev->irq_enabled)
293 mutex_unlock(&dev->struct_mutex);
294 return -EBUSY; 261 return -EBUSY;
295 }
296 dev->irq_enabled = true; 262 dev->irq_enabled = true;
297 mutex_unlock(&dev->struct_mutex);
298 263
299 DRM_DEBUG("irq=%d\n", drm_dev_to_irq(dev)); 264 DRM_DEBUG("irq=%d\n", irq);
300 265
301 /* Before installing handler */ 266 /* Before installing handler */
302 if (dev->driver->irq_preinstall) 267 if (dev->driver->irq_preinstall)
@@ -306,18 +271,11 @@ int drm_irq_install(struct drm_device *dev)
306 if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED)) 271 if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED))
307 sh_flags = IRQF_SHARED; 272 sh_flags = IRQF_SHARED;
308 273
309 if (dev->devname) 274 ret = request_irq(irq, dev->driver->irq_handler,
310 irqname = dev->devname; 275 sh_flags, dev->driver->name, dev);
311 else
312 irqname = dev->driver->name;
313
314 ret = request_irq(drm_dev_to_irq(dev), dev->driver->irq_handler,
315 sh_flags, irqname, dev);
316 276
317 if (ret < 0) { 277 if (ret < 0) {
318 mutex_lock(&dev->struct_mutex);
319 dev->irq_enabled = false; 278 dev->irq_enabled = false;
320 mutex_unlock(&dev->struct_mutex);
321 return ret; 279 return ret;
322 } 280 }
323 281
@@ -329,12 +287,12 @@ int drm_irq_install(struct drm_device *dev)
329 ret = dev->driver->irq_postinstall(dev); 287 ret = dev->driver->irq_postinstall(dev);
330 288
331 if (ret < 0) { 289 if (ret < 0) {
332 mutex_lock(&dev->struct_mutex);
333 dev->irq_enabled = false; 290 dev->irq_enabled = false;
334 mutex_unlock(&dev->struct_mutex);
335 if (!drm_core_check_feature(dev, DRIVER_MODESET)) 291 if (!drm_core_check_feature(dev, DRIVER_MODESET))
336 vga_client_register(dev->pdev, NULL, NULL, NULL); 292 vga_client_register(dev->pdev, NULL, NULL, NULL);
337 free_irq(drm_dev_to_irq(dev), dev); 293 free_irq(irq, dev);
294 } else {
295 dev->irq = irq;
338 } 296 }
339 297
340 return ret; 298 return ret;
@@ -357,10 +315,8 @@ int drm_irq_uninstall(struct drm_device *dev)
357 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 315 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
358 return -EINVAL; 316 return -EINVAL;
359 317
360 mutex_lock(&dev->struct_mutex);
361 irq_enabled = dev->irq_enabled; 318 irq_enabled = dev->irq_enabled;
362 dev->irq_enabled = false; 319 dev->irq_enabled = false;
363 mutex_unlock(&dev->struct_mutex);
364 320
365 /* 321 /*
366 * Wake up any waiters so they don't hang. 322 * Wake up any waiters so they don't hang.
@@ -379,7 +335,7 @@ int drm_irq_uninstall(struct drm_device *dev)
379 if (!irq_enabled) 335 if (!irq_enabled)
380 return -EINVAL; 336 return -EINVAL;
381 337
382 DRM_DEBUG("irq=%d\n", drm_dev_to_irq(dev)); 338 DRM_DEBUG("irq=%d\n", dev->irq);
383 339
384 if (!drm_core_check_feature(dev, DRIVER_MODESET)) 340 if (!drm_core_check_feature(dev, DRIVER_MODESET))
385 vga_client_register(dev->pdev, NULL, NULL, NULL); 341 vga_client_register(dev->pdev, NULL, NULL, NULL);
@@ -387,7 +343,7 @@ int drm_irq_uninstall(struct drm_device *dev)
387 if (dev->driver->irq_uninstall) 343 if (dev->driver->irq_uninstall)
388 dev->driver->irq_uninstall(dev); 344 dev->driver->irq_uninstall(dev);
389 345
390 free_irq(drm_dev_to_irq(dev), dev); 346 free_irq(dev->irq, dev);
391 347
392 return 0; 348 return 0;
393} 349}
@@ -408,28 +364,38 @@ int drm_control(struct drm_device *dev, void *data,
408 struct drm_file *file_priv) 364 struct drm_file *file_priv)
409{ 365{
410 struct drm_control *ctl = data; 366 struct drm_control *ctl = data;
367 int ret = 0, irq;
411 368
412 /* if we haven't irq we fallback for compatibility reasons - 369 /* if we haven't irq we fallback for compatibility reasons -
413 * this used to be a separate function in drm_dma.h 370 * this used to be a separate function in drm_dma.h
414 */ 371 */
415 372
373 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
374 return 0;
375 if (drm_core_check_feature(dev, DRIVER_MODESET))
376 return 0;
377 /* UMS was only ever support on pci devices. */
378 if (WARN_ON(!dev->pdev))
379 return -EINVAL;
416 380
417 switch (ctl->func) { 381 switch (ctl->func) {
418 case DRM_INST_HANDLER: 382 case DRM_INST_HANDLER:
419 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 383 irq = dev->pdev->irq;
420 return 0; 384
421 if (drm_core_check_feature(dev, DRIVER_MODESET))
422 return 0;
423 if (dev->if_version < DRM_IF_VERSION(1, 2) && 385 if (dev->if_version < DRM_IF_VERSION(1, 2) &&
424 ctl->irq != drm_dev_to_irq(dev)) 386 ctl->irq != irq)
425 return -EINVAL; 387 return -EINVAL;
426 return drm_irq_install(dev); 388 mutex_lock(&dev->struct_mutex);
389 ret = drm_irq_install(dev, irq);
390 mutex_unlock(&dev->struct_mutex);
391
392 return ret;
427 case DRM_UNINST_HANDLER: 393 case DRM_UNINST_HANDLER:
428 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 394 mutex_lock(&dev->struct_mutex);
429 return 0; 395 ret = drm_irq_uninstall(dev);
430 if (drm_core_check_feature(dev, DRIVER_MODESET)) 396 mutex_unlock(&dev->struct_mutex);
431 return 0; 397
432 return drm_irq_uninstall(dev); 398 return ret;
433 default: 399 default:
434 return -EINVAL; 400 return -EINVAL;
435 } 401 }
@@ -1160,9 +1126,8 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
1160 int ret; 1126 int ret;
1161 unsigned int flags, seq, crtc, high_crtc; 1127 unsigned int flags, seq, crtc, high_crtc;
1162 1128
1163 if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 1129 if (!dev->irq_enabled)
1164 if ((!drm_dev_to_irq(dev)) || (!dev->irq_enabled)) 1130 return -EINVAL;
1165 return -EINVAL;
1166 1131
1167 if (vblwait->request.type & _DRM_VBLANK_SIGNAL) 1132 if (vblwait->request.type & _DRM_VBLANK_SIGNAL)
1168 return -EINVAL; 1133 return -EINVAL;
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 9c696a5ad74d..d237de36a07a 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -137,21 +137,9 @@ static int drm_get_pci_domain(struct drm_device *dev)
137 return pci_domain_nr(dev->pdev->bus); 137 return pci_domain_nr(dev->pdev->bus);
138} 138}
139 139
140static int drm_pci_get_irq(struct drm_device *dev)
141{
142 return dev->pdev->irq;
143}
144
145static const char *drm_pci_get_name(struct drm_device *dev)
146{
147 struct pci_driver *pdriver = dev->driver->kdriver.pci;
148 return pdriver->name;
149}
150
151static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master) 140static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
152{ 141{
153 int len, ret; 142 int len, ret;
154 struct pci_driver *pdriver = dev->driver->kdriver.pci;
155 master->unique_len = 40; 143 master->unique_len = 40;
156 master->unique_size = master->unique_len; 144 master->unique_size = master->unique_len;
157 master->unique = kmalloc(master->unique_size, GFP_KERNEL); 145 master->unique = kmalloc(master->unique_size, GFP_KERNEL);
@@ -173,29 +161,16 @@ static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
173 } else 161 } else
174 master->unique_len = len; 162 master->unique_len = len;
175 163
176 dev->devname =
177 kmalloc(strlen(pdriver->name) +
178 master->unique_len + 2, GFP_KERNEL);
179
180 if (dev->devname == NULL) {
181 ret = -ENOMEM;
182 goto err;
183 }
184
185 sprintf(dev->devname, "%s@%s", pdriver->name,
186 master->unique);
187
188 return 0; 164 return 0;
189err: 165err:
190 return ret; 166 return ret;
191} 167}
192 168
193static int drm_pci_set_unique(struct drm_device *dev, 169int drm_pci_set_unique(struct drm_device *dev,
194 struct drm_master *master, 170 struct drm_master *master,
195 struct drm_unique *u) 171 struct drm_unique *u)
196{ 172{
197 int domain, bus, slot, func, ret; 173 int domain, bus, slot, func, ret;
198 const char *bus_name;
199 174
200 master->unique_len = u->unique_len; 175 master->unique_len = u->unique_len;
201 master->unique_size = u->unique_len + 1; 176 master->unique_size = u->unique_len + 1;
@@ -212,17 +187,6 @@ static int drm_pci_set_unique(struct drm_device *dev,
212 187
213 master->unique[master->unique_len] = '\0'; 188 master->unique[master->unique_len] = '\0';
214 189
215 bus_name = dev->driver->bus->get_name(dev);
216 dev->devname = kmalloc(strlen(bus_name) +
217 strlen(master->unique) + 2, GFP_KERNEL);
218 if (!dev->devname) {
219 ret = -ENOMEM;
220 goto err;
221 }
222
223 sprintf(dev->devname, "%s@%s", bus_name,
224 master->unique);
225
226 /* Return error if the busid submitted doesn't match the device's actual 190 /* Return error if the busid submitted doesn't match the device's actual
227 * busid. 191 * busid.
228 */ 192 */
@@ -247,7 +211,6 @@ err:
247 return ret; 211 return ret;
248} 212}
249 213
250
251static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p) 214static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)
252{ 215{
253 if ((p->busnum >> 8) != drm_get_pci_domain(dev) || 216 if ((p->busnum >> 8) != drm_get_pci_domain(dev) ||
@@ -262,6 +225,37 @@ static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)
262 return 0; 225 return 0;
263} 226}
264 227
228/**
229 * Get interrupt from bus id.
230 *
231 * \param inode device inode.
232 * \param file_priv DRM file private.
233 * \param cmd command.
234 * \param arg user argument, pointing to a drm_irq_busid structure.
235 * \return zero on success or a negative number on failure.
236 *
237 * Finds the PCI device with the specified bus id and gets its IRQ number.
238 * This IOCTL is deprecated, and will now return EINVAL for any busid not equal
239 * to that of the device that this DRM instance attached to.
240 */
241int drm_irq_by_busid(struct drm_device *dev, void *data,
242 struct drm_file *file_priv)
243{
244 struct drm_irq_busid *p = data;
245
246 if (drm_core_check_feature(dev, DRIVER_MODESET))
247 return -EINVAL;
248
249 /* UMS was only ever support on PCI devices. */
250 if (WARN_ON(!dev->pdev))
251 return -EINVAL;
252
253 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
254 return -EINVAL;
255
256 return drm_pci_irq_by_busid(dev, p);
257}
258
265static void drm_pci_agp_init(struct drm_device *dev) 259static void drm_pci_agp_init(struct drm_device *dev)
266{ 260{
267 if (drm_core_check_feature(dev, DRIVER_USE_AGP)) { 261 if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
@@ -287,12 +281,7 @@ void drm_pci_agp_destroy(struct drm_device *dev)
287} 281}
288 282
289static struct drm_bus drm_pci_bus = { 283static struct drm_bus drm_pci_bus = {
290 .bus_type = DRIVER_BUS_PCI,
291 .get_irq = drm_pci_get_irq,
292 .get_name = drm_pci_get_name,
293 .set_busid = drm_pci_set_busid, 284 .set_busid = drm_pci_set_busid,
294 .set_unique = drm_pci_set_unique,
295 .irq_by_busid = drm_pci_irq_by_busid,
296}; 285};
297 286
298/** 287/**
@@ -375,7 +364,6 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
375 364
376 DRM_DEBUG("\n"); 365 DRM_DEBUG("\n");
377 366
378 driver->kdriver.pci = pdriver;
379 driver->bus = &drm_pci_bus; 367 driver->bus = &drm_pci_bus;
380 368
381 if (driver->driver_features & DRIVER_MODESET) 369 if (driver->driver_features & DRIVER_MODESET)
@@ -453,6 +441,19 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
453} 441}
454 442
455void drm_pci_agp_destroy(struct drm_device *dev) {} 443void drm_pci_agp_destroy(struct drm_device *dev) {}
444
445int drm_irq_by_busid(struct drm_device *dev, void *data,
446 struct drm_file *file_priv)
447{
448 return -EINVAL;
449}
450
451int drm_pci_set_unique(struct drm_device *dev,
452 struct drm_master *master,
453 struct drm_unique *u)
454{
455 return -EINVAL;
456}
456#endif 457#endif
457 458
458EXPORT_SYMBOL(drm_pci_init); 459EXPORT_SYMBOL(drm_pci_init);
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index 319ff5385601..234e0bc1ae51 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -68,16 +68,6 @@ err_free:
68 return ret; 68 return ret;
69} 69}
70 70
71static int drm_platform_get_irq(struct drm_device *dev)
72{
73 return platform_get_irq(dev->platformdev, 0);
74}
75
76static const char *drm_platform_get_name(struct drm_device *dev)
77{
78 return dev->platformdev->name;
79}
80
81static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master) 71static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master)
82{ 72{
83 int len, ret, id; 73 int len, ret, id;
@@ -106,26 +96,12 @@ static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *mas
106 goto err; 96 goto err;
107 } 97 }
108 98
109 dev->devname =
110 kmalloc(strlen(dev->platformdev->name) +
111 master->unique_len + 2, GFP_KERNEL);
112
113 if (dev->devname == NULL) {
114 ret = -ENOMEM;
115 goto err;
116 }
117
118 sprintf(dev->devname, "%s@%s", dev->platformdev->name,
119 master->unique);
120 return 0; 99 return 0;
121err: 100err:
122 return ret; 101 return ret;
123} 102}
124 103
125static struct drm_bus drm_platform_bus = { 104static struct drm_bus drm_platform_bus = {
126 .bus_type = DRIVER_BUS_PLATFORM,
127 .get_irq = drm_platform_get_irq,
128 .get_name = drm_platform_get_name,
129 .set_busid = drm_platform_set_busid, 105 .set_busid = drm_platform_set_busid,
130}; 106};
131 107
@@ -145,7 +121,6 @@ int drm_platform_init(struct drm_driver *driver, struct platform_device *platfor
145{ 121{
146 DRM_DEBUG("\n"); 122 DRM_DEBUG("\n");
147 123
148 driver->kdriver.platform_device = platform_device;
149 driver->bus = &drm_platform_bus; 124 driver->bus = &drm_platform_bus;
150 return drm_get_platform_dev(platform_device, driver); 125 return drm_get_platform_dev(platform_device, driver);
151} 126}
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index bfa6cb949545..1447b0ee3676 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -169,9 +169,6 @@ static void drm_master_destroy(struct kref *kref)
169 master->unique_len = 0; 169 master->unique_len = 0;
170 } 170 }
171 171
172 kfree(dev->devname);
173 dev->devname = NULL;
174
175 list_for_each_entry_safe(pt, next, &master->magicfree, head) { 172 list_for_each_entry_safe(pt, next, &master->magicfree, head) {
176 list_del(&pt->head); 173 list_del(&pt->head);
177 drm_ht_remove_item(&master->magiclist, &pt->hash_item); 174 drm_ht_remove_item(&master->magiclist, &pt->hash_item);
@@ -572,7 +569,7 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
572 INIT_LIST_HEAD(&dev->maplist); 569 INIT_LIST_HEAD(&dev->maplist);
573 INIT_LIST_HEAD(&dev->vblank_event_list); 570 INIT_LIST_HEAD(&dev->vblank_event_list);
574 571
575 spin_lock_init(&dev->count_lock); 572 spin_lock_init(&dev->buf_lock);
576 spin_lock_init(&dev->event_lock); 573 spin_lock_init(&dev->event_lock);
577 mutex_init(&dev->struct_mutex); 574 mutex_init(&dev->struct_mutex);
578 mutex_init(&dev->ctxlist_mutex); 575 mutex_init(&dev->ctxlist_mutex);
@@ -651,8 +648,6 @@ static void drm_dev_release(struct kref *ref)
651 drm_minor_free(dev, DRM_MINOR_RENDER); 648 drm_minor_free(dev, DRM_MINOR_RENDER);
652 drm_minor_free(dev, DRM_MINOR_CONTROL); 649 drm_minor_free(dev, DRM_MINOR_CONTROL);
653 650
654 kfree(dev->devname);
655
656 mutex_destroy(&dev->master_mutex); 651 mutex_destroy(&dev->master_mutex);
657 kfree(dev); 652 kfree(dev);
658} 653}
diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
index c3406aad2944..c6c7c29ad46f 100644
--- a/drivers/gpu/drm/drm_usb.c
+++ b/drivers/gpu/drm/drm_usb.c
@@ -36,16 +36,6 @@ err_free:
36} 36}
37EXPORT_SYMBOL(drm_get_usb_dev); 37EXPORT_SYMBOL(drm_get_usb_dev);
38 38
39static int drm_usb_get_irq(struct drm_device *dev)
40{
41 return 0;
42}
43
44static const char *drm_usb_get_name(struct drm_device *dev)
45{
46 return "USB";
47}
48
49static int drm_usb_set_busid(struct drm_device *dev, 39static int drm_usb_set_busid(struct drm_device *dev,
50 struct drm_master *master) 40 struct drm_master *master)
51{ 41{
@@ -53,9 +43,6 @@ static int drm_usb_set_busid(struct drm_device *dev,
53} 43}
54 44
55static struct drm_bus drm_usb_bus = { 45static struct drm_bus drm_usb_bus = {
56 .bus_type = DRIVER_BUS_USB,
57 .get_irq = drm_usb_get_irq,
58 .get_name = drm_usb_get_name,
59 .set_busid = drm_usb_set_busid, 46 .set_busid = drm_usb_set_busid,
60}; 47};
61 48
@@ -64,7 +51,6 @@ int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
64 int res; 51 int res;
65 DRM_DEBUG("\n"); 52 DRM_DEBUG("\n");
66 53
67 driver->kdriver.usb = udriver;
68 driver->bus = &drm_usb_bus; 54 driver->bus = &drm_usb_bus;
69 55
70 res = usb_register(udriver); 56 res = usb_register(udriver);
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index b686e56646eb..0a3101a3db19 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -354,7 +354,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
354 PSB_WVDC32(0xFFFFFFFF, PSB_INT_MASK_R); 354 PSB_WVDC32(0xFFFFFFFF, PSB_INT_MASK_R);
355 spin_unlock_irqrestore(&dev_priv->irqmask_lock, irqflags); 355 spin_unlock_irqrestore(&dev_priv->irqmask_lock, irqflags);
356 356
357 drm_irq_install(dev); 357 drm_irq_install(dev, dev->pdev->irq);
358 358
359 dev->vblank_disable_allowed = true; 359 dev->vblank_disable_allowed = true;
360 dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */ 360 dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 0b38f88c35f0..58f2c467d68e 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1280,12 +1280,13 @@ static void i915_switcheroo_set_state(struct pci_dev *pdev, enum vga_switcheroo_
1280static bool i915_switcheroo_can_switch(struct pci_dev *pdev) 1280static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
1281{ 1281{
1282 struct drm_device *dev = pci_get_drvdata(pdev); 1282 struct drm_device *dev = pci_get_drvdata(pdev);
1283 bool can_switch;
1284 1283
1285 spin_lock(&dev->count_lock); 1284 /*
1286 can_switch = (dev->open_count == 0); 1285 * FIXME: open_count is protected by drm_global_mutex but that would lead to
1287 spin_unlock(&dev->count_lock); 1286 * locking inversion with the driver load path. And the access here is
1288 return can_switch; 1287 * completely racy anyway. So don't bother with locking for now.
1288 */
1289 return dev->open_count == 0;
1289} 1290}
1290 1291
1291static const struct vga_switcheroo_client_ops i915_switcheroo_ops = { 1292static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {
@@ -1329,7 +1330,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
1329 1330
1330 intel_power_domains_init_hw(dev_priv); 1331 intel_power_domains_init_hw(dev_priv);
1331 1332
1332 ret = drm_irq_install(dev); 1333 ret = drm_irq_install(dev, dev->pdev->irq);
1333 if (ret) 1334 if (ret)
1334 goto cleanup_gem_stolen; 1335 goto cleanup_gem_stolen;
1335 1336
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 5d8250f7145d..254b3236200b 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -574,7 +574,7 @@ static int __i915_drm_thaw(struct drm_device *dev, bool restore_gtt_mappings)
574 mutex_unlock(&dev->struct_mutex); 574 mutex_unlock(&dev->struct_mutex);
575 575
576 /* We need working interrupts for modeset enabling ... */ 576 /* We need working interrupts for modeset enabling ... */
577 drm_irq_install(dev); 577 drm_irq_install(dev, dev->pdev->irq);
578 578
579 intel_modeset_init_hw(dev); 579 intel_modeset_init_hw(dev);
580 580
@@ -746,8 +746,13 @@ int i915_reset(struct drm_device *dev)
746 return ret; 746 return ret;
747 } 747 }
748 748
749 /*
750 * FIXME: This is horribly race against concurrent pageflip and
751 * vblank wait ioctls since they can observe dev->irqs_disabled
752 * being false when they shouldn't be able to.
753 */
749 drm_irq_uninstall(dev); 754 drm_irq_uninstall(dev);
750 drm_irq_install(dev); 755 drm_irq_install(dev, dev->pdev->irq);
751 756
752 /* rps/rc6 re-init is necessary to restore state lost after the 757 /* rps/rc6 re-init is necessary to restore state lost after the
753 * reset and the re-install of drm irq. Skip for ironlake per 758 * reset and the re-install of drm irq. Skip for ironlake per
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 8f5ffab15894..5c8b86196c84 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4523,16 +4523,15 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
4523 } 4523 }
4524 4524
4525 BUG_ON(!list_empty(&dev_priv->gtt.base.active_list)); 4525 BUG_ON(!list_empty(&dev_priv->gtt.base.active_list));
4526 mutex_unlock(&dev->struct_mutex);
4527 4526
4528 ret = drm_irq_install(dev); 4527 ret = drm_irq_install(dev, dev->pdev->irq);
4529 if (ret) 4528 if (ret)
4530 goto cleanup_ringbuffer; 4529 goto cleanup_ringbuffer;
4530 mutex_unlock(&dev->struct_mutex);
4531 4531
4532 return 0; 4532 return 0;
4533 4533
4534cleanup_ringbuffer: 4534cleanup_ringbuffer:
4535 mutex_lock(&dev->struct_mutex);
4536 i915_gem_cleanup_ringbuffer(dev); 4535 i915_gem_cleanup_ringbuffer(dev);
4537 dev_priv->ums.mm_suspended = 1; 4536 dev_priv->ums.mm_suspended = 1;
4538 mutex_unlock(&dev->struct_mutex); 4537 mutex_unlock(&dev->struct_mutex);
@@ -4547,7 +4546,9 @@ i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
4547 if (drm_core_check_feature(dev, DRIVER_MODESET)) 4546 if (drm_core_check_feature(dev, DRIVER_MODESET))
4548 return 0; 4547 return 0;
4549 4548
4549 mutex_lock(&dev->struct_mutex);
4550 drm_irq_uninstall(dev); 4550 drm_irq_uninstall(dev);
4551 mutex_unlock(&dev->struct_mutex);
4551 4552
4552 return i915_gem_suspend(dev); 4553 return i915_gem_suspend(dev);
4553} 4554}
diff --git a/drivers/gpu/drm/mga/mga_state.c b/drivers/gpu/drm/mga/mga_state.c
index 314685b7f41f..3cb58df5237e 100644
--- a/drivers/gpu/drm/mga/mga_state.c
+++ b/drivers/gpu/drm/mga/mga_state.c
@@ -1020,7 +1020,7 @@ static int mga_getparam(struct drm_device *dev, void *data, struct drm_file *fil
1020 1020
1021 switch (param->param) { 1021 switch (param->param) {
1022 case MGA_PARAM_IRQ_NR: 1022 case MGA_PARAM_IRQ_NR:
1023 value = drm_dev_to_irq(dev); 1023 value = dev->pdev->irq;
1024 break; 1024 break;
1025 case MGA_PARAM_CARD_TYPE: 1025 case MGA_PARAM_CARD_TYPE:
1026 value = dev_priv->chipset; 1026 value = dev_priv->chipset;
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index f9de156b9e65..50ec1bed5820 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -288,7 +288,7 @@ static int msm_load(struct drm_device *dev, unsigned long flags)
288 } 288 }
289 289
290 pm_runtime_get_sync(dev->dev); 290 pm_runtime_get_sync(dev->dev);
291 ret = drm_irq_install(dev); 291 ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
292 pm_runtime_put_sync(dev->dev); 292 pm_runtime_put_sync(dev->dev);
293 if (ret < 0) { 293 if (ret < 0) {
294 dev_err(dev->dev, "failed to install IRQ handler\n"); 294 dev_err(dev->dev, "failed to install IRQ handler\n");
diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
index fb84da3cb50d..4f4c3fec6916 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
@@ -64,12 +64,13 @@ static bool
64nouveau_switcheroo_can_switch(struct pci_dev *pdev) 64nouveau_switcheroo_can_switch(struct pci_dev *pdev)
65{ 65{
66 struct drm_device *dev = pci_get_drvdata(pdev); 66 struct drm_device *dev = pci_get_drvdata(pdev);
67 bool can_switch;
68 67
69 spin_lock(&dev->count_lock); 68 /*
70 can_switch = (dev->open_count == 0); 69 * FIXME: open_count is protected by drm_global_mutex but that would lead to
71 spin_unlock(&dev->count_lock); 70 * locking inversion with the driver load path. And the access here is
72 return can_switch; 71 * completely racy anyway. So don't bother with locking for now.
72 */
73 return dev->open_count == 0;
73} 74}
74 75
75static const struct vga_switcheroo_client_ops 76static const struct vga_switcheroo_client_ops
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index fee8748bdca5..6e936634d65c 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -214,7 +214,6 @@ static struct pci_driver qxl_pci_driver = {
214static struct drm_driver qxl_driver = { 214static struct drm_driver qxl_driver = {
215 .driver_features = DRIVER_GEM | DRIVER_MODESET | 215 .driver_features = DRIVER_GEM | DRIVER_MODESET |
216 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED, 216 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
217 .dev_priv_size = 0,
218 .load = qxl_driver_load, 217 .load = qxl_driver_load,
219 .unload = qxl_driver_unload, 218 .unload = qxl_driver_unload,
220 219
diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
index 28f84b4fce32..34d6a85e9023 100644
--- a/drivers/gpu/drm/qxl/qxl_irq.c
+++ b/drivers/gpu/drm/qxl/qxl_irq.c
@@ -87,7 +87,7 @@ int qxl_irq_init(struct qxl_device *qdev)
87 atomic_set(&qdev->irq_received_cursor, 0); 87 atomic_set(&qdev->irq_received_cursor, 0);
88 atomic_set(&qdev->irq_received_io_cmd, 0); 88 atomic_set(&qdev->irq_received_io_cmd, 0);
89 qdev->irq_received_error = 0; 89 qdev->irq_received_error = 0;
90 ret = drm_irq_install(qdev->ddev); 90 ret = drm_irq_install(qdev->ddev, qdev->ddev->pdev->irq);
91 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK; 91 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
92 if (unlikely(ret != 0)) { 92 if (unlikely(ret != 0)) {
93 DRM_ERROR("Failed installing irq: %d\n", ret); 93 DRM_ERROR("Failed installing irq: %d\n", ret);
diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
index e806dacd452f..97064dd434c2 100644
--- a/drivers/gpu/drm/r128/r128_state.c
+++ b/drivers/gpu/drm/r128/r128_state.c
@@ -1594,7 +1594,7 @@ static int r128_getparam(struct drm_device *dev, void *data, struct drm_file *fi
1594 1594
1595 switch (param->param) { 1595 switch (param->param) {
1596 case R128_PARAM_IRQ_NR: 1596 case R128_PARAM_IRQ_NR:
1597 value = drm_dev_to_irq(dev); 1597 value = dev->pdev->irq;
1598 break; 1598 break;
1599 default: 1599 default:
1600 return -EINVAL; 1600 return -EINVAL;
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 511fe26198e4..9aa1afd1786e 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1125,12 +1125,13 @@ static void radeon_switcheroo_set_state(struct pci_dev *pdev, enum vga_switchero
1125static bool radeon_switcheroo_can_switch(struct pci_dev *pdev) 1125static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
1126{ 1126{
1127 struct drm_device *dev = pci_get_drvdata(pdev); 1127 struct drm_device *dev = pci_get_drvdata(pdev);
1128 bool can_switch;
1129 1128
1130 spin_lock(&dev->count_lock); 1129 /*
1131 can_switch = (dev->open_count == 0); 1130 * FIXME: open_count is protected by drm_global_mutex but that would lead to
1132 spin_unlock(&dev->count_lock); 1131 * locking inversion with the driver load path. And the access here is
1133 return can_switch; 1132 * completely racy anyway. So don't bother with locking for now.
1133 */
1134 return dev->open_count == 0;
1134} 1135}
1135 1136
1136static const struct vga_switcheroo_client_ops radeon_switcheroo_ops = { 1137static const struct vga_switcheroo_client_ops radeon_switcheroo_ops = {
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index c00a2f585185..15447a4119f4 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -519,7 +519,6 @@ static struct drm_driver kms_driver = {
519 DRIVER_USE_AGP | 519 DRIVER_USE_AGP |
520 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | 520 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM |
521 DRIVER_PRIME | DRIVER_RENDER, 521 DRIVER_PRIME | DRIVER_RENDER,
522 .dev_priv_size = 0,
523 .load = radeon_driver_load_kms, 522 .load = radeon_driver_load_kms,
524 .open = radeon_driver_open_kms, 523 .open = radeon_driver_open_kms,
525 .preclose = radeon_driver_preclose_kms, 524 .preclose = radeon_driver_preclose_kms,
diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
index 089c9ffb0aa9..16807afab362 100644
--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
@@ -287,7 +287,7 @@ int radeon_irq_kms_init(struct radeon_device *rdev)
287 INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func); 287 INIT_WORK(&rdev->reset_work, radeon_irq_reset_work_func);
288 288
289 rdev->irq.installed = true; 289 rdev->irq.installed = true;
290 r = drm_irq_install(rdev->ddev); 290 r = drm_irq_install(rdev->ddev, rdev->ddev->pdev->irq);
291 if (r) { 291 if (r) {
292 rdev->irq.installed = false; 292 rdev->irq.installed = false;
293 flush_work(&rdev->hotplug_work); 293 flush_work(&rdev->hotplug_work);
diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
index 956ab7f14e16..b576549fc783 100644
--- a/drivers/gpu/drm/radeon/radeon_state.c
+++ b/drivers/gpu/drm/radeon/radeon_state.c
@@ -3054,7 +3054,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
3054 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600) 3054 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
3055 value = 0; 3055 value = 0;
3056 else 3056 else
3057 value = drm_dev_to_irq(dev); 3057 value = dev->pdev->irq;
3058 break; 3058 break;
3059 case RADEON_PARAM_GART_BASE: 3059 case RADEON_PARAM_GART_BASE:
3060 value = dev_priv->gart_vm_start; 3060 value = dev_priv->gart_vm_start;
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index c839c9c89efb..82c84c7fd4f6 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -185,7 +185,7 @@ static int shmob_drm_load(struct drm_device *dev, unsigned long flags)
185 goto done; 185 goto done;
186 } 186 }
187 187
188 ret = drm_irq_install(dev); 188 ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
189 if (ret < 0) { 189 if (ret < 0) {
190 dev_err(&pdev->dev, "failed to install IRQ handler\n"); 190 dev_err(&pdev->dev, "failed to install IRQ handler\n");
191 goto done; 191 goto done;
diff --git a/drivers/gpu/drm/tegra/bus.c b/drivers/gpu/drm/tegra/bus.c
index 71cef5c13dc8..b3a66d65cb53 100644
--- a/drivers/gpu/drm/tegra/bus.c
+++ b/drivers/gpu/drm/tegra/bus.c
@@ -12,9 +12,7 @@ static int drm_host1x_set_busid(struct drm_device *dev,
12 struct drm_master *master) 12 struct drm_master *master)
13{ 13{
14 const char *device = dev_name(dev->dev); 14 const char *device = dev_name(dev->dev);
15 const char *driver = dev->driver->name;
16 const char *bus = dev->dev->bus->name; 15 const char *bus = dev->dev->bus->name;
17 int length;
18 16
19 master->unique_len = strlen(bus) + 1 + strlen(device); 17 master->unique_len = strlen(bus) + 1 + strlen(device);
20 master->unique_size = master->unique_len; 18 master->unique_size = master->unique_len;
@@ -25,19 +23,10 @@ static int drm_host1x_set_busid(struct drm_device *dev,
25 23
26 snprintf(master->unique, master->unique_len + 1, "%s:%s", bus, device); 24 snprintf(master->unique, master->unique_len + 1, "%s:%s", bus, device);
27 25
28 length = strlen(driver) + 1 + master->unique_len;
29
30 dev->devname = kmalloc(length + 1, GFP_KERNEL);
31 if (!dev->devname)
32 return -ENOMEM;
33
34 snprintf(dev->devname, length + 1, "%s@%s", driver, master->unique);
35
36 return 0; 26 return 0;
37} 27}
38 28
39static struct drm_bus drm_host1x_bus = { 29static struct drm_bus drm_host1x_bus = {
40 .bus_type = DRIVER_BUS_HOST1X,
41 .set_busid = drm_host1x_set_busid, 30 .set_busid = drm_host1x_set_busid,
42}; 31};
43 32
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 171a8203892c..b20b69488dc9 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -268,7 +268,7 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
268 } 268 }
269 269
270 pm_runtime_get_sync(dev->dev); 270 pm_runtime_get_sync(dev->dev);
271 ret = drm_irq_install(dev); 271 ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
272 pm_runtime_put_sync(dev->dev); 272 pm_runtime_put_sync(dev->dev);
273 if (ret < 0) { 273 if (ret < 0) {
274 dev_err(dev->dev, "failed to install IRQ handler\n"); 274 dev_err(dev->dev, "failed to install IRQ handler\n");
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 4a223bbea3b3..6bdd15eea7e8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -806,7 +806,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
806 } 806 }
807 807
808 if (dev_priv->capabilities & SVGA_CAP_IRQMASK) { 808 if (dev_priv->capabilities & SVGA_CAP_IRQMASK) {
809 ret = drm_irq_install(dev); 809 ret = drm_irq_install(dev, dev->pdev->irq);
810 if (ret != 0) { 810 if (ret != 0) {
811 DRM_ERROR("Failed installing irq: %d\n", ret); 811 DRM_ERROR("Failed installing irq: %d\n", ret);
812 goto out_no_irq; 812 goto out_no_irq;