summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2015-02-10 01:39:33 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2015-02-10 01:39:33 +0000
commitc167416fc15ca7a2bda326257804173c37f601d6 (patch)
treed861dc7b5dede2ad56cd338f0ba88a784bf0a1a6
parentebb560bc8aba730612e6dde6aa18d10ea1933b6a (diff)
Remove DRM_LOCK macros, rename dev_lock to struct_mutex and directly
call linux style lock functions where these macros were used.
-rw-r--r--sys/dev/pci/drm/drmP.h14
-rw-r--r--sys/dev/pci/drm/drm_drv.c76
-rw-r--r--sys/dev/pci/drm/drm_irq.c18
-rw-r--r--sys/dev/pci/drm/i915/i915_dma.c10
-rw-r--r--sys/dev/pci/drm/i915/i915_drv.c18
-rw-r--r--sys/dev/pci/drm/i915/i915_gem.c92
-rw-r--r--sys/dev/pci/drm/i915/i915_gem_context.c10
-rw-r--r--sys/dev/pci/drm/i915/i915_gem_execbuffer.c20
-rw-r--r--sys/dev/pci/drm/i915/i915_gem_tiling.c10
-rw-r--r--sys/dev/pci/drm/i915/i915_irq.c6
-rw-r--r--sys/dev/pci/drm/i915/i915_suspend.c10
-rw-r--r--sys/dev/pci/drm/i915/intel_display.c62
-rw-r--r--sys/dev/pci/drm/i915/intel_fb.c8
-rw-r--r--sys/dev/pci/drm/i915/intel_overlay.c22
-rw-r--r--sys/dev/pci/drm/i915/intel_pm.c16
-rw-r--r--sys/dev/pci/drm/i915/intel_sprite.c14
-rw-r--r--sys/dev/pci/drm/radeon/radeon_kms.c6
-rw-r--r--sys/dev/pci/drm/radeon/radeon_object.c6
-rw-r--r--sys/dev/pci/drm/radeon/radeon_pm.c8
19 files changed, 211 insertions, 215 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index 3133bbcbb33..3011ba62efb 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: drmP.h,v 1.178 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: drmP.h,v 1.179 2015/02/10 01:39:32 jsg Exp $ */
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
*/
@@ -85,10 +85,6 @@
#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
#define DRM_CURRENTPID curproc->p_pid
-#define DRM_LOCK() rw_enter_write(&dev->dev_lock)
-#define DRM_UNLOCK() rw_exit_write(&dev->dev_lock)
-#define DRM_READLOCK() rw_enter_read(&dev->dev_lock)
-#define DRM_READUNLOCK() rw_exit_read(&dev->dev_lock)
#define DRM_MAXUNITS 8
/* DRM_SUSER returns true if the user is superuser */
@@ -799,7 +795,7 @@ struct drm_device {
int if_version; /* Highest interface version set */
/* Locks */
- struct rwlock dev_lock; /* protects everything else */
+ struct rwlock struct_mutex; /* protects everything else */
/* Usage Counters */
int open_count; /* Outstanding files open */
@@ -808,7 +804,7 @@ struct drm_device {
SPLAY_HEAD(drm_file_tree, drm_file) files;
drm_magic_t magicid;
- /* Linked list of mappable regions. Protected by dev_lock */
+ /* Linked list of mappable regions. Protected by struct_mutex */
struct extent *handle_ext;
TAILQ_HEAD(drm_map_list, drm_local_map) maplist;
@@ -1071,9 +1067,9 @@ drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
{
struct drm_device *dev = obj->dev;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
drm_unref(&obj->uobj);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
static __inline__ int drm_core_check_feature(struct drm_device *dev,
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index 3abf6587660..03cca82e83d 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_drv.c,v 1.131 2014/09/24 10:35:39 jsg Exp $ */
+/* $OpenBSD: drm_drv.c,v 1.132 2015/02/10 01:39:32 jsg Exp $ */
/*-
* Copyright 2007-2009 Owain G. Ainsworth <oga@openbsd.org>
* Copyright © 2008 Intel Corporation
@@ -219,7 +219,7 @@ drm_attach(struct device *parent, struct device *self, void *aux)
dev->pc = da->pc;
dev->bridgetag = da->bridgetag;
- rw_init(&dev->dev_lock, "drmdevlk");
+ rw_init(&dev->struct_mutex, "drmdevlk");
mtx_init(&dev->event_lock, IPL_TTY);
mtx_init(&dev->quiesce_mtx, IPL_NONE);
@@ -445,13 +445,13 @@ drmopen(dev_t kdev, int flags, int fmt, struct proc *p)
if (flags & O_EXCL)
return (EBUSY); /* No exclusive opens */
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
if (dev->open_count++ == 0) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
if ((ret = drm_firstopen(dev)) != 0)
goto err;
} else {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
/* always allocate at least enough space for our data */
@@ -485,10 +485,10 @@ drmopen(dev_t kdev, int flags, int fmt, struct proc *p)
}
}
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
/* first opener automatically becomes master if root */
if (SPLAY_EMPTY(&dev->files) && !DRM_SUSER(p)) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
ret = EPERM;
goto free_priv;
}
@@ -496,16 +496,16 @@ drmopen(dev_t kdev, int flags, int fmt, struct proc *p)
file_priv->master = SPLAY_EMPTY(&dev->files);
SPLAY_INSERT(drm_file_tree, &dev->files, file_priv);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return (0);
free_priv:
drm_free(file_priv);
err:
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
--dev->open_count;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return (ret);
}
@@ -523,14 +523,14 @@ drmclose(dev_t kdev, int flags, int fmt, struct proc *p)
DRM_DEBUG("open_count = %d\n", dev->open_count);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
file_priv = drm_find_file_by_minor(dev, minor(kdev));
if (file_priv == NULL) {
DRM_ERROR("can't find authenticator\n");
retcode = EINVAL;
goto done;
}
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
if (dev->driver->close != NULL)
dev->driver->close(dev, file_priv);
@@ -558,7 +558,7 @@ drmclose(dev_t kdev, int flags, int fmt, struct proc *p)
if (dev->driver->flags & DRIVER_MODESET)
drm_fb_release(dev, file_priv);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
if (dev->driver->flags & DRIVER_GEM) {
struct drm_handle *han;
mtx_enter(&file_priv->table_lock);
@@ -579,10 +579,10 @@ drmclose(dev_t kdev, int flags, int fmt, struct proc *p)
done:
if (--dev->open_count == 0) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
retcode = drm_lastclose(dev);
} else
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return (retcode);
}
@@ -592,9 +592,9 @@ drm_do_ioctl(struct drm_device *dev, int minor, u_long cmd, caddr_t data)
{
struct drm_file *file_priv;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
file_priv = drm_find_file_by_minor(dev, minor);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
if (file_priv == NULL) {
DRM_ERROR("can't find authenticator\n");
return EINVAL;
@@ -794,9 +794,9 @@ drmread(dev_t kdev, struct uio *uio, int ioflag)
if (dev == NULL)
return (ENXIO);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
file_priv = drm_find_file_by_minor(dev, minor(kdev));
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
if (file_priv == NULL)
return (ENXIO);
@@ -877,9 +877,9 @@ drmpoll(dev_t kdev, int events, struct proc *p)
if (dev == NULL)
return (POLLERR);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
file_priv = drm_find_file_by_minor(dev, minor(kdev));
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
if (file_priv == NULL)
return (POLLERR);
@@ -900,12 +900,12 @@ drm_getsarea(struct drm_device *dev)
{
struct drm_local_map *map;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
TAILQ_FOREACH(map, &dev->maplist, link) {
if (map->type == _DRM_SHM && (map->flags & _DRM_CONTAINS_LOCK))
break;
}
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return (map);
}
@@ -920,9 +920,9 @@ drmmmap(dev_t kdev, off_t offset, int prot)
if (dev == NULL)
return (-1);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
file_priv = drm_find_file_by_minor(dev, minor(kdev));
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
if (file_priv == NULL) {
DRM_ERROR("can't find authenticator\n");
return (-1);
@@ -952,7 +952,7 @@ drmmmap(dev_t kdev, off_t offset, int prot)
* for performance, even if the list was a
* bit longer.
*/
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
TAILQ_FOREACH(map, &dev->maplist, link) {
if (offset >= map->ext &&
offset < map->ext + map->size) {
@@ -962,17 +962,17 @@ drmmmap(dev_t kdev, off_t offset, int prot)
}
if (map == NULL) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("can't find map\n");
return (-1);
}
if (((map->flags & _DRM_RESTRICTED) && file_priv->master == 0)) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("restricted map\n");
return (-1);
}
type = map->type;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
switch (type) {
#if __OS_HAS_AGP
@@ -1192,9 +1192,9 @@ drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
if (file_priv->magic) {
auth->magic = file_priv->magic;
} else {
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
file_priv->magic = auth->magic = dev->magicid++;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("%d\n", auth->magic);
}
@@ -1217,7 +1217,7 @@ drm_authmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
if (auth->magic == 0)
return (ret);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
SPLAY_FOREACH(p, drm_file_tree, &dev->files) {
if (p->magic == auth->magic) {
p->authenticated = 1;
@@ -1226,7 +1226,7 @@ drm_authmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
break;
}
}
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return (ret);
}
@@ -1616,9 +1616,9 @@ drm_gem_object_handle_unreference_unlocked(struct drm_gem_object *obj)
{
struct drm_device *dev = obj->dev;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
drm_gem_object_handle_unreference(obj);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
/**
@@ -1705,20 +1705,20 @@ udv_attach_drm(dev_t device, vm_prot_t accessprot, voff_t off, vsize_t size)
if (dev->driver->mmap)
return dev->driver->mmap(dev, off, size);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
TAILQ_FOREACH(map, &dev->maplist, link) {
if (off >= map->ext && off + size <= map->ext + map->size)
break;
}
if (map == NULL || map->type != _DRM_GEM) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return NULL;
}
obj = (struct drm_gem_object *)map->handle;
drm_ref(&obj->uobj);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return &obj->uobj;
}
diff --git a/sys/dev/pci/drm/drm_irq.c b/sys/dev/pci/drm/drm_irq.c
index e9c871d53c3..0a0e1f63d67 100644
--- a/sys/dev/pci/drm/drm_irq.c
+++ b/sys/dev/pci/drm/drm_irq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_irq.c,v 1.55 2014/09/13 16:06:37 doug Exp $ */
+/* $OpenBSD: drm_irq.c,v 1.56 2015/02/10 01:39:32 jsg Exp $ */
/**
* \file drm_irq.c
* IRQ support
@@ -378,13 +378,13 @@ int drm_irq_install(struct drm_device *dev)
DRM_DEBUG("irq=%d\n", dev->irq);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
if (dev->irq_enabled) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return (EBUSY);
}
dev->irq_enabled = 1;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
if (dev->driver->irq_install) {
if ((ret = dev->driver->irq_install(dev)) != 0)
@@ -398,9 +398,9 @@ int drm_irq_install(struct drm_device *dev)
return (0);
err:
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
dev->irq_enabled = 0;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return (ret);
}
EXPORT_SYMBOL(drm_irq_install);
@@ -416,14 +416,14 @@ int drm_irq_uninstall(struct drm_device *dev)
{
int i;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
if (!dev->irq_enabled) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return (EINVAL);
}
dev->irq_enabled = 0;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
/*
* Ick. we're about to turn of vblanks, so make sure anyone waiting
diff --git a/sys/dev/pci/drm/i915/i915_dma.c b/sys/dev/pci/drm/i915/i915_dma.c
index 3a21fe91b44..59b4b646a50 100644
--- a/sys/dev/pci/drm/i915/i915_dma.c
+++ b/sys/dev/pci/drm/i915/i915_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_dma.c,v 1.16 2014/02/18 02:36:49 jsg Exp $ */
+/* $OpenBSD: i915_dma.c,v 1.17 2015/02/10 01:39:32 jsg Exp $ */
/* i915_dma.c -- DMA support for the I915 -*- linux-c -*-
*/
/*
@@ -357,9 +357,9 @@ i915_load_modeset_init(struct drm_device *dev)
cleanup_irq:
drm_irq_uninstall(dev);
cleanup_gem:
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
i915_gem_cleanup_ringbuffer(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
i915_gem_cleanup_aliasing_ppgtt(dev);
cleanup_gem_stolen:
#ifdef notyet
@@ -407,9 +407,9 @@ i915_driver_close(struct drm_device *dev, struct drm_file *file)
{
struct drm_i915_file_private *file_priv = file->driver_priv;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
i915_gem_context_close(dev, file);
i915_gem_release(dev, file);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
kfree(file_priv);
}
diff --git a/sys/dev/pci/drm/i915/i915_drv.c b/sys/dev/pci/drm/i915/i915_drv.c
index c1b0c1a0eaf..ddeba9450d0 100644
--- a/sys/dev/pci/drm/i915/i915_drv.c
+++ b/sys/dev/pci/drm/i915/i915_drv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_drv.c,v 1.71 2015/02/09 03:15:41 dlg Exp $ */
+/* $OpenBSD: i915_drv.c,v 1.72 2015/02/10 01:39:32 jsg Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -539,11 +539,11 @@ __i915_drm_thaw(struct drm_device *dev)
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
intel_init_pch_refclk(dev);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
dev_priv->mm.suspended = 0;
error = i915_gem_init_hw(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
intel_modeset_init_hw(dev);
drm_mode_config_reset(dev);
@@ -566,9 +566,9 @@ i915_drm_thaw(struct drm_device *dev)
intel_gt_sanitize(dev);
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
i915_gem_restore_gtt_mappings(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
__i915_drm_thaw(dev);
@@ -1584,7 +1584,7 @@ int i915_reset(struct drm_device *dev)
return 0;
#endif
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
i915_gem_reset(dev);
@@ -1597,7 +1597,7 @@ int i915_reset(struct drm_device *dev)
dev_priv->last_gpu_reset = time_second;
if (ret) {
DRM_ERROR("Failed to reset chip.\n");
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -1638,12 +1638,12 @@ int i915_reset(struct drm_device *dev)
* some unknown reason, this blows up my ilk, so don't.
*/
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
drm_irq_uninstall(dev);
drm_irq_install(dev);
} else {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
return 0;
diff --git a/sys/dev/pci/drm/i915/i915_gem.c b/sys/dev/pci/drm/i915/i915_gem.c
index d42b9232ff0..73f0a124abf 100644
--- a/sys/dev/pci/drm/i915/i915_gem.c
+++ b/sys/dev/pci/drm/i915/i915_gem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_gem.c,v 1.79 2015/01/27 03:17:36 dlg Exp $ */
+/* $OpenBSD: i915_gem.c,v 1.80 2015/02/10 01:39:32 jsg Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -159,7 +159,7 @@ int i915_mutex_lock_interruptible(struct drm_device *dev)
if (ret)
return ret;
- ret = -rw_enter(&dev->dev_lock, RW_WRITE | RW_INTR);
+ ret = -rw_enter(&dev->struct_mutex, RW_WRITE | RW_INTR);
if (ret)
return ret;
@@ -190,10 +190,10 @@ i915_gem_init_ioctl(struct drm_device *dev, void *data,
if (INTEL_INFO(dev)->gen >= 5)
return -ENODEV;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
i915_gem_init_global_gtt(dev, args->gtt_start,
args->gtt_end, args->gtt_end);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return 0;
}
@@ -208,11 +208,11 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
size_t pinned;
pinned = 0;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
list_for_each_entry(obj, &dev_priv->mm.bound_list, gtt_list)
if (obj->pin_count)
pinned += obj->gtt_space->size;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
args->aper_size = dev_priv->mm.gtt_total;
args->aper_available_size = args->aper_size - pinned;
@@ -584,7 +584,7 @@ i915_gem_shmem_pread(struct drm_device *dev,
goto next_page;
hit_slowpath = 1;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
#ifdef __linux__
if (!prefaulted) {
@@ -602,7 +602,7 @@ i915_gem_shmem_pread(struct drm_device *dev,
user_data, page_do_bit17_swizzling,
needs_clflush);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
next_page:
#ifdef __linux__
@@ -669,7 +669,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
out:
drm_gem_object_unreference(&obj->base);
unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -951,13 +951,13 @@ i915_gem_shmem_pwrite(struct drm_device *dev,
goto next_page;
hit_slowpath = 1;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
ret = shmem_pwrite_slow(page, shmem_page_offset, page_length,
user_data, page_do_bit17_swizzling,
partial_cacheline_write,
needs_clflush_after);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
next_page:
#ifdef __linux__
@@ -1058,7 +1058,7 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
out:
drm_gem_object_unreference(&obj->base);
unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -1288,7 +1288,7 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj,
u32 seqno;
int ret;
- rw_assert_wrlock(&dev->dev_lock);
+ rw_assert_wrlock(&dev->struct_mutex);
BUG_ON(!dev_priv->mm.interruptible);
seqno = readonly ? obj->last_write_seqno : obj->last_read_seqno;
@@ -1303,9 +1303,9 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj,
if (ret)
return ret;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
ret = __wait_seqno(ring, seqno, true, NULL);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
i915_gem_retire_requests_ring(ring);
@@ -1383,7 +1383,7 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
unref:
drm_gem_object_unreference(&obj->base);
unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -1414,7 +1414,7 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
drm_gem_object_unreference(&obj->base);
unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -1484,7 +1484,7 @@ i915_gem_fault(struct drm_gem_object *gem_obj, struct uvm_faultinfo *ufi,
* copyout in one of the fast paths. Return failure such that
* we fall back on the slow path.
*/
- if (!obj->base.map || RWLOCK_OWNER(&dev->dev_lock) == curproc) {
+ if (!obj->base.map || RWLOCK_OWNER(&dev->struct_mutex) == curproc) {
uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap,
&obj->base.uobj, NULL);
dev_priv->entries--;
@@ -1493,13 +1493,13 @@ i915_gem_fault(struct drm_gem_object *gem_obj, struct uvm_faultinfo *ufi,
offset -= obj->base.map->ext;
- if (rw_enter(&dev->dev_lock, RW_NOSLEEP | RW_WRITE) != 0) {
+ if (rw_enter(&dev->struct_mutex, RW_NOSLEEP | RW_WRITE) != 0) {
uvmfault_unlockall(ufi, NULL, &obj->base.uobj, NULL);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
locked = uvmfault_relock(ufi);
}
if (!locked) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
dev_priv->entries--;
return (VM_PAGER_REFAULT);
}
@@ -1544,7 +1544,7 @@ i915_gem_fault(struct drm_gem_object *gem_obj, struct uvm_faultinfo *ufi,
i915_gem_object_unpin(obj);
uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap,
NULL, NULL);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
dev_priv->entries--;
pmap_update(ufi->orig_map->pmap);
uvm_wait("intelflt");
@@ -1555,7 +1555,7 @@ unpin:
i915_gem_object_unpin(obj);
unlock:
uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, NULL, NULL);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
dev_priv->entries--;
pmap_update(ufi->orig_map->pmap);
@@ -1792,7 +1792,7 @@ i915_gem_mmap_gtt(struct drm_file *file,
out:
drm_gem_object_unreference(&obj->base);
unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -2475,7 +2475,7 @@ i915_gem_retire_work_handler(void *arg1)
dev = (struct drm_device *)dev_priv->drmdev;
/* Come back later if the device is busy... */
- if (rw_enter(&dev->dev_lock, RW_NOSLEEP | RW_WRITE)) {
+ if (rw_enter(&dev->struct_mutex, RW_NOSLEEP | RW_WRITE)) {
timeout_add_sec(&dev_priv->mm.retire_timer, 1);
return;
}
@@ -2498,7 +2498,7 @@ i915_gem_retire_work_handler(void *arg1)
if (idle)
intel_mark_idle(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
/**
@@ -2565,7 +2565,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->bo_handle));
if (&obj->base == NULL) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return -ENOENT;
}
@@ -2591,7 +2591,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
}
drm_gem_object_unreference(&obj->base);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
ret = __wait_seqno(ring, seqno, true, timeout);
if (timeout) {
@@ -2602,7 +2602,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
out:
drm_gem_object_unreference(&obj->base);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -3453,7 +3453,7 @@ int i915_gem_get_caching_ioctl(struct drm_device *dev, void *data,
drm_gem_object_unreference(&obj->base);
unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -3490,7 +3490,7 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
drm_gem_object_unreference(&obj->base);
unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -3775,7 +3775,7 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data,
out:
drm_gem_object_unreference(&obj->base);
unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -3812,7 +3812,7 @@ i915_gem_unpin_ioctl(struct drm_device *dev, void *data,
out:
drm_gem_object_unreference(&obj->base);
unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -3849,7 +3849,7 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
drm_gem_object_unreference(&obj->base);
unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -3905,7 +3905,7 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
out:
drm_gem_object_unreference(&obj->base);
unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -4009,16 +4009,16 @@ i915_gem_idle(struct drm_device *dev)
drm_i915_private_t *dev_priv = dev->dev_private;
int ret;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
if (dev_priv->mm.suspended) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return 0;
}
ret = i915_gpu_idle(dev);
if (ret) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
i915_gem_retire_requests(dev);
@@ -4039,7 +4039,7 @@ i915_gem_idle(struct drm_device *dev)
i915_kernel_lost_context(dev);
i915_gem_cleanup_ringbuffer(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
/* Cancel the retire work handler, which should be idle now. */
timeout_del(&dev_priv->mm.retire_timer);
@@ -4203,7 +4203,7 @@ int i915_gem_init(struct drm_device *dev)
gtt_size = dev_priv->mm.gtt->gtt_total_entries << PAGE_SHIFT;
mappable_size = dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
#ifdef notyet
if (intel_enable_ppgtt(dev) && HAS_ALIASING_PPGTT(dev)) {
/* PPGTT pdes are stolen from global gtt ptes, so shrink the
@@ -4236,7 +4236,7 @@ int i915_gem_init(struct drm_device *dev)
#endif
ret = i915_gem_init_hw(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
if (ret) {
i915_gem_cleanup_aliasing_ppgtt(dev);
return ret;
@@ -4276,17 +4276,17 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
atomic_set(&dev_priv->mm.wedged, 0);
}
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
dev_priv->mm.suspended = 0;
ret = i915_gem_init_hw(dev);
if (ret != 0) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
BUG_ON(!list_empty(&dev_priv->mm.active_list));
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
ret = drm_irq_install(dev);
if (ret)
@@ -4295,10 +4295,10 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
return 0;
cleanup_ringbuffer:
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
i915_gem_cleanup_ringbuffer(dev);
dev_priv->mm.suspended = 1;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
diff --git a/sys/dev/pci/drm/i915/i915_gem_context.c b/sys/dev/pci/drm/i915/i915_gem_context.c
index 66f1c63a48f..08d36ca0aab 100644
--- a/sys/dev/pci/drm/i915/i915_gem_context.c
+++ b/sys/dev/pci/drm/i915/i915_gem_context.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_gem_context.c,v 1.9 2014/07/12 18:48:52 tedu Exp $ */
+/* $OpenBSD: i915_gem_context.c,v 1.10 2015/02/10 01:39:32 jsg Exp $ */
/*
* Copyright © 2011-2012 Intel Corporation
*
@@ -225,7 +225,7 @@ static int create_default_context(struct drm_i915_private *dev_priv)
struct drm_device *dev = (struct drm_device *)dev_priv->drmdev;
int ret;
- rw_assert_wrlock(&dev->dev_lock);
+ rw_assert_wrlock(&dev->struct_mutex);
ctx = create_hw_context(dev, NULL);
if (IS_ERR(ctx))
@@ -520,7 +520,7 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
return ret;
ctx = create_hw_context(dev, file_priv);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
if (IS_ERR(ctx))
return PTR_ERR(ctx);
@@ -547,13 +547,13 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
ctx = i915_gem_context_get(file_priv, args->ctx_id);
if (!ctx) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return -ENOENT;
}
do_destroy(ctx);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
DRM_DEBUG_DRIVER("HW context %d destroyed\n", args->ctx_id);
return 0;
diff --git a/sys/dev/pci/drm/i915/i915_gem_execbuffer.c b/sys/dev/pci/drm/i915/i915_gem_execbuffer.c
index 00c7b31b2d1..ed1a52bf4d8 100644
--- a/sys/dev/pci/drm/i915/i915_gem_execbuffer.c
+++ b/sys/dev/pci/drm/i915/i915_gem_execbuffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_gem_execbuffer.c,v 1.31 2014/12/09 07:05:06 doug Exp $ */
+/* $OpenBSD: i915_gem_execbuffer.c,v 1.32 2015/02/10 01:39:32 jsg Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -536,7 +536,7 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
drm_gem_object_unreference(&obj->base);
}
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
total = 0;
for (i = 0; i < count; i++)
@@ -548,7 +548,7 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
if (reloc == NULL || reloc_offset == NULL) {
drm_free(reloc);
drm_free(reloc_offset);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
return -ENOMEM;
}
@@ -563,7 +563,7 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
if (DRM_COPY_FROM_USER(reloc+total, user_relocs,
exec[i].relocation_count * sizeof(*reloc))) {
ret = -EFAULT;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
goto err;
}
@@ -581,7 +581,7 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
&invalid_offset,
sizeof(invalid_offset))) {
ret = -EFAULT;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
goto err;
}
}
@@ -592,7 +592,7 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
ret = i915_mutex_lock_interruptible(dev);
if (ret) {
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
goto err;
}
@@ -961,14 +961,14 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
goto pre_mutex_err;
if (dev_priv->mm.suspended) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
ret = -EBUSY;
goto pre_mutex_err;
}
eb = eb_create(args->buffer_count);
if (eb == NULL) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
ret = -ENOMEM;
goto pre_mutex_err;
}
@@ -1019,7 +1019,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
&objects, eb,
exec,
args->buffer_count);
- rw_assert_wrlock(&dev->dev_lock);
+ rw_assert_wrlock(&dev->struct_mutex);
}
if (ret)
goto err;
@@ -1113,7 +1113,7 @@ err:
drm_gem_object_unreference(&obj->base);
}
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
pre_mutex_err:
#ifdef __linux
diff --git a/sys/dev/pci/drm/i915/i915_gem_tiling.c b/sys/dev/pci/drm/i915/i915_gem_tiling.c
index bf1d2a1dcd0..fb72cd32f84 100644
--- a/sys/dev/pci/drm/i915/i915_gem_tiling.c
+++ b/sys/dev/pci/drm/i915/i915_gem_tiling.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_gem_tiling.c,v 1.15 2014/11/16 12:31:00 deraadt Exp $ */
+/* $OpenBSD: i915_gem_tiling.c,v 1.16 2015/02/10 01:39:32 jsg Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -370,7 +370,7 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
}
}
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
if (args->tiling_mode != obj->tiling_mode ||
args->stride != obj->stride) {
/* We need to rebind the object if its current allocation
@@ -417,7 +417,7 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
args->stride = obj->stride;
args->tiling_mode = obj->tiling_mode;
drm_gem_object_unreference(&obj->base);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return ret;
}
@@ -437,7 +437,7 @@ i915_gem_get_tiling(struct drm_device *dev, void *data,
if (&obj->base == NULL)
return -ENOENT;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
args->tiling_mode = obj->tiling_mode;
switch (obj->tiling_mode) {
@@ -461,7 +461,7 @@ i915_gem_get_tiling(struct drm_device *dev, void *data,
args->swizzle_mode = I915_BIT_6_SWIZZLE_9_10;
drm_gem_object_unreference(&obj->base);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return 0;
}
diff --git a/sys/dev/pci/drm/i915/i915_irq.c b/sys/dev/pci/drm/i915/i915_irq.c
index 4ed53ad19b1..75c2de3b944 100644
--- a/sys/dev/pci/drm/i915/i915_irq.c
+++ b/sys/dev/pci/drm/i915/i915_irq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_irq.c,v 1.14 2015/01/27 03:17:36 dlg Exp $ */
+/* $OpenBSD: i915_irq.c,v 1.15 2015/02/10 01:39:32 jsg Exp $ */
/* i915_irq.c -- IRQ support for the I915 -*- linux-c -*-
*/
/*
@@ -414,7 +414,7 @@ static void ivybridge_parity_work(void *arg1)
* In order to prevent a get/put style interface, acquire struct mutex
* any time we access those registers.
*/
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
misccpctl = I915_READ(GEN7_MISCCPCTL);
I915_WRITE(GEN7_MISCCPCTL, misccpctl & ~GEN7_DOP_CLOCK_GATE_ENABLE);
@@ -436,7 +436,7 @@ static void ivybridge_parity_work(void *arg1)
I915_WRITE(GTIMR, dev_priv->gt_irq_mask);
mtx_leave(&dev_priv->irq_lock);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
#if 0
parity_event[0] = "L3_PARITY_ERROR=1";
diff --git a/sys/dev/pci/drm/i915/i915_suspend.c b/sys/dev/pci/drm/i915/i915_suspend.c
index 370ff96924e..3feaebfd2f3 100644
--- a/sys/dev/pci/drm/i915/i915_suspend.c
+++ b/sys/dev/pci/drm/i915/i915_suspend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_suspend.c,v 1.4 2013/08/13 10:23:50 jsg Exp $ */
+/* $OpenBSD: i915_suspend.c,v 1.5 2015/02/10 01:39:32 jsg Exp $ */
/*
*
* Copyright 2008 (c) Intel Corporation
@@ -811,7 +811,7 @@ int i915_save_state(struct drm_device *dev)
dev_priv->regfile.saveLBB = pci_conf_read(dev_priv->pc, dev_priv->tag, LBB);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
i915_save_display(dev);
@@ -849,7 +849,7 @@ int i915_save_state(struct drm_device *dev)
for (i = 0; i < 3; i++)
dev_priv->regfile.saveSWF2[i] = I915_READ(SWF30 + (i << 2));
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return 0;
}
@@ -861,7 +861,7 @@ int i915_restore_state(struct drm_device *dev)
pci_conf_write(dev_priv->pc, dev_priv->tag, LBB, dev_priv->regfile.saveLBB);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
i915_restore_display(dev);
@@ -894,7 +894,7 @@ int i915_restore_state(struct drm_device *dev)
for (i = 0; i < 3; i++)
I915_WRITE(SWF30 + (i << 2), dev_priv->regfile.saveSWF2[i]);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
#ifdef notyet
intel_i2c_reset(dev);
diff --git a/sys/dev/pci/drm/i915/intel_display.c b/sys/dev/pci/drm/i915/intel_display.c
index 4488f61a7ba..a630d8e5424 100644
--- a/sys/dev/pci/drm/i915/intel_display.c
+++ b/sys/dev/pci/drm/i915/intel_display.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intel_display.c,v 1.38 2015/01/27 03:17:36 dlg Exp $ */
+/* $OpenBSD: intel_display.c,v 1.39 2015/02/10 01:39:32 jsg Exp $ */
/*
* Copyright © 2006-2007 Intel Corporation
*
@@ -2420,12 +2420,12 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
return -EINVAL;
}
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
ret = intel_pin_and_fence_fb_obj(dev,
to_intel_framebuffer(fb)->obj,
NULL);
if (ret != 0) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
DRM_ERROR("pin & fence failed\n");
return ret;
}
@@ -2436,7 +2436,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
ret = dev_priv->display.update_plane(crtc, fb, x, y);
if (ret) {
intel_unpin_fb_obj(to_intel_framebuffer(fb)->obj);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
DRM_ERROR("failed to update base address\n");
return ret;
}
@@ -2452,7 +2452,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
}
intel_update_fbc(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
intel_crtc_update_sarea_pos(crtc, x, y);
@@ -3061,9 +3061,9 @@ static void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc)
while (intel_crtc_has_pending_flip(crtc))
tsleep(&dev_priv->pending_flip_queue, 0, "915wfl", 0);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
intel_finish_fb(crtc->fb);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
static bool ironlake_crtc_driving_pch(struct drm_crtc *crtc)
@@ -3490,9 +3490,9 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
if (is_pch_port)
ironlake_pch_enable(crtc);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
intel_update_fbc(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
intel_crtc_update_cursor(crtc, true);
@@ -3570,9 +3570,9 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
if (is_pch_port)
lpt_pch_enable(crtc);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
intel_update_fbc(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
intel_crtc_update_cursor(crtc, true);
@@ -3665,9 +3665,9 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)
intel_crtc->active = false;
intel_update_watermarks(dev);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
intel_update_fbc(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
static void haswell_crtc_disable(struct drm_crtc *crtc)
@@ -3720,9 +3720,9 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
intel_crtc->active = false;
intel_update_watermarks(dev);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
intel_update_fbc(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
static void ironlake_crtc_off(struct drm_crtc *crtc)
@@ -3748,11 +3748,11 @@ static void intel_crtc_dpms_overlay(struct intel_crtc *intel_crtc, bool enable)
struct drm_device *dev = intel_crtc->base.dev;
struct drm_i915_private *dev_priv = dev->dev_private;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
dev_priv->mm.interruptible = false;
(void) intel_overlay_switch_off(intel_crtc->overlay);
dev_priv->mm.interruptible = true;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
/* Let userspace switch the overlay on again. In most cases userspace
@@ -3912,9 +3912,9 @@ static void intel_crtc_disable(struct drm_crtc *crtc)
assert_pipe_disabled(dev->dev_private, to_intel_crtc(crtc)->pipe);
if (crtc->fb) {
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
intel_unpin_fb_obj(to_intel_framebuffer(crtc->fb)->obj);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
crtc->fb = NULL;
}
@@ -6566,7 +6566,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
DRM_DEBUG_KMS("cursor off\n");
addr = 0;
obj = NULL;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
goto finish;
}
@@ -6587,7 +6587,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
}
/* we only need to pin inside GTT if cursor is non-phy */
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
if (!dev_priv->info->cursor_needs_physical) {
if (obj->tiling_mode) {
DRM_ERROR("cursor cannot be tiled\n");
@@ -6633,7 +6633,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
drm_gem_object_unreference(&intel_crtc->cursor_bo->base);
}
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
intel_crtc->cursor_addr = addr;
intel_crtc->cursor_bo = obj;
@@ -6647,7 +6647,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
fail_unpin:
i915_gem_object_unpin(obj);
fail_locked:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
fail:
drm_gem_object_unreference_unlocked(&obj->base);
return ret;
@@ -7189,13 +7189,13 @@ static void intel_unpin_work_fn(void *arg1)
struct intel_unpin_work *work = arg1;
struct drm_device *dev = work->crtc->dev;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
intel_unpin_fb_obj(work->old_fb_obj);
drm_gem_object_unreference(&work->pending_flip_obj->base);
drm_gem_object_unreference(&work->old_fb_obj->base);
intel_update_fbc(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
BUG_ON(atomic_read(&to_intel_crtc(work->crtc)->unpin_work_count) == 0);
atomic_dec(&to_intel_crtc(work->crtc)->unpin_work_count);
@@ -7626,7 +7626,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
intel_disable_fbc(dev);
intel_mark_fb_busy(obj);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
// trace_i915_flip_request(intel_crtc->plane, obj);
@@ -7638,7 +7638,7 @@ cleanup_pending:
atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
drm_gem_object_unreference(&work->old_fb_obj->base);
drm_gem_object_unreference(&obj->base);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
cleanup:
mtx_enter(&dev->event_lock);
@@ -9104,9 +9104,9 @@ void intel_modeset_init_hw(struct drm_device *dev)
intel_init_clock_gating(dev);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
intel_enable_gt_powersave(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
void intel_modeset_init(struct drm_device *dev)
@@ -9497,7 +9497,7 @@ void intel_modeset_cleanup(struct drm_device *dev)
struct intel_crtc *intel_crtc;
drm_kms_helper_poll_fini(dev);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
#ifdef notyet
intel_unregister_dsm_handler();
@@ -9522,7 +9522,7 @@ void intel_modeset_cleanup(struct drm_device *dev)
if (IS_VALLEYVIEW(dev))
vlv_init_dpio(dev);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
/* Disable the irq before mode object teardown, for the irq might
* enqueue unpin/hotplug work. */
diff --git a/sys/dev/pci/drm/i915/intel_fb.c b/sys/dev/pci/drm/i915/intel_fb.c
index c2ff357db63..9a349e85de5 100644
--- a/sys/dev/pci/drm/i915/intel_fb.c
+++ b/sys/dev/pci/drm/i915/intel_fb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intel_fb.c,v 1.10 2014/01/30 15:10:48 kettenis Exp $ */
+/* $OpenBSD: intel_fb.c,v 1.11 2015/02/10 01:39:32 jsg Exp $ */
/*
* Copyright © 2007 David Airlie
*
@@ -67,7 +67,7 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
goto out;
}
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
/* Flush everything out, we'll be doing GTT only from now on */
ret = intel_pin_and_fence_fb_obj(dev, obj, false);
@@ -175,7 +175,7 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
fb->width, fb->height,
obj->gtt_offset, obj);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
#if 1
DRM_DEBUG_KMS("skipping call to vga_switcheroo_client_fb_set\n");
#else
@@ -187,7 +187,7 @@ out_unpin:
i915_gem_object_unpin(obj);
out_unref:
drm_gem_object_unreference(&obj->base);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
out:
return ret;
}
diff --git a/sys/dev/pci/drm/i915/intel_overlay.c b/sys/dev/pci/drm/i915/intel_overlay.c
index 5a79df3e181..69a01cf2315 100644
--- a/sys/dev/pci/drm/i915/intel_overlay.c
+++ b/sys/dev/pci/drm/i915/intel_overlay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intel_overlay.c,v 1.9 2014/03/24 17:06:49 kettenis Exp $ */
+/* $OpenBSD: intel_overlay.c,v 1.10 2015/02/10 01:39:32 jsg Exp $ */
/*
* Copyright © 2009
*
@@ -1070,11 +1070,11 @@ int intel_overlay_put_image(struct drm_device *dev, void *data,
if (!(put_image_rec->flags & I915_OVERLAY_ENABLE)) {
rw_enter_write(&dev->mode_config.rwl);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
ret = intel_overlay_switch_off(overlay);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
rw_exit_write(&dev->mode_config.rwl);
return ret;
@@ -1100,7 +1100,7 @@ int intel_overlay_put_image(struct drm_device *dev, void *data,
}
rw_enter_write(&dev->mode_config.rwl);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
if (new_bo->tiling_mode) {
DRM_ERROR("buffer used for overlay image can not be tiled\n");
@@ -1180,7 +1180,7 @@ int intel_overlay_put_image(struct drm_device *dev, void *data,
if (ret != 0)
goto out_unlock;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
rw_exit_write(&dev->mode_config.rwl);
kfree(params);
@@ -1188,7 +1188,7 @@ int intel_overlay_put_image(struct drm_device *dev, void *data,
return 0;
out_unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
rw_exit_write(&dev->mode_config.rwl);
drm_gem_object_unreference_unlocked(&new_bo->base);
out_free:
@@ -1265,7 +1265,7 @@ int intel_overlay_attrs(struct drm_device *dev, void *data,
}
rw_enter_write(&dev->mode_config.rwl);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
ret = -EINVAL;
if (!(attrs->flags & I915_OVERLAY_UPDATE_ATTRS)) {
@@ -1329,7 +1329,7 @@ int intel_overlay_attrs(struct drm_device *dev, void *data,
ret = 0;
out_unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
rw_exit_write(&dev->mode_config.rwl);
return ret;
@@ -1350,7 +1350,7 @@ void intel_setup_overlay(struct drm_device *dev)
if (!overlay)
return;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
if (WARN_ON(dev_priv->overlay))
goto out_free;
@@ -1402,7 +1402,7 @@ void intel_setup_overlay(struct drm_device *dev)
intel_overlay_unmap_regs(overlay, regs);
dev_priv->overlay = overlay;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("initialized overlay support\n");
return;
@@ -1412,7 +1412,7 @@ out_unpin_bo:
out_free_bo:
drm_gem_object_unreference(&reg_bo->base);
out_free:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
kfree(overlay);
return;
}
diff --git a/sys/dev/pci/drm/i915/intel_pm.c b/sys/dev/pci/drm/i915/intel_pm.c
index e337f5c16b7..c138295f3d9 100644
--- a/sys/dev/pci/drm/i915/intel_pm.c
+++ b/sys/dev/pci/drm/i915/intel_pm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intel_pm.c,v 1.22 2015/01/27 03:17:36 dlg Exp $ */
+/* $OpenBSD: intel_pm.c,v 1.23 2015/02/10 01:39:32 jsg Exp $ */
/*
* Copyright © 2012 Intel Corporation
*
@@ -281,7 +281,7 @@ static void intel_fbc_work_fn(void *arg1)
struct drm_device *dev = work->crtc->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
if (work == dev_priv->fbc_work) {
/* Double check that we haven't switched fb without cancelling
* the prior work.
@@ -297,7 +297,7 @@ static void intel_fbc_work_fn(void *arg1)
dev_priv->fbc_work = NULL;
}
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
kfree(work);
}
@@ -2310,7 +2310,7 @@ err_unpin:
i915_gem_object_unpin(ctx);
err_unref:
drm_gem_object_unreference(&ctx->base);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return NULL;
}
@@ -4118,7 +4118,7 @@ void intel_init_power_wells(struct drm_device *dev)
if (!IS_HASWELL(dev))
return;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
for (i = 0; i < ARRAY_SIZE(power_wells); i++) {
int well = I915_READ(power_wells[i]);
@@ -4135,7 +4135,7 @@ void intel_init_power_wells(struct drm_device *dev)
}
}
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
/* Set up chip specific power management-related functions */
@@ -4491,11 +4491,11 @@ void intel_gt_init(struct drm_device *dev)
* (correctly) interpreted by the test below as MT
* forcewake being disabled.
*/
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
__gen6_gt_force_wake_mt_get(dev_priv);
ecobus = I915_READ_NOTRACE(ECOBUS);
__gen6_gt_force_wake_mt_put(dev_priv);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
if (ecobus & FORCEWAKE_MT_ENABLE) {
dev_priv->gt.force_wake_get =
diff --git a/sys/dev/pci/drm/i915/intel_sprite.c b/sys/dev/pci/drm/i915/intel_sprite.c
index e483356ea4c..d61caf0e5bd 100644
--- a/sys/dev/pci/drm/i915/intel_sprite.c
+++ b/sys/dev/pci/drm/i915/intel_sprite.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intel_sprite.c,v 1.4 2014/01/21 08:57:22 kettenis Exp $ */
+/* $OpenBSD: intel_sprite.c,v 1.5 2015/02/10 01:39:32 jsg Exp $ */
/*
* Copyright © 2011 Intel Corporation
*
@@ -504,7 +504,7 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
(crtc_w == primary_w) && (crtc_h == primary_h))
disable_primary = true;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
if (ret)
@@ -534,15 +534,15 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
* do the pin & ref bookkeeping.
*/
if (old_obj != obj) {
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
intel_wait_for_vblank(dev, to_intel_crtc(crtc)->pipe);
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
}
intel_unpin_fb_obj(old_obj);
}
out_unlock:
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
out:
return ret;
}
@@ -561,10 +561,10 @@ intel_disable_plane(struct drm_plane *plane)
if (!intel_plane->obj)
goto out;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
intel_unpin_fb_obj(intel_plane->obj);
intel_plane->obj = NULL;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
out:
return ret;
diff --git a/sys/dev/pci/drm/radeon/radeon_kms.c b/sys/dev/pci/drm/radeon/radeon_kms.c
index a7aabbdf2d1..700c510e486 100644
--- a/sys/dev/pci/drm/radeon/radeon_kms.c
+++ b/sys/dev/pci/drm/radeon/radeon_kms.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radeon_kms.c,v 1.32 2015/01/27 03:17:36 dlg Exp $ */
+/* $OpenBSD: radeon_kms.c,v 1.33 2015/02/10 01:39:32 jsg Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
@@ -795,7 +795,7 @@ radeon_set_filp_rights(struct drm_device *dev,
struct drm_file *applier,
uint32_t *value)
{
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
if (*value == 1) {
/* wants rights */
if (!*owner)
@@ -806,7 +806,7 @@ radeon_set_filp_rights(struct drm_device *dev,
*owner = NULL;
}
*value = *owner == applier ? 1 : 0;
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
/*
diff --git a/sys/dev/pci/drm/radeon/radeon_object.c b/sys/dev/pci/drm/radeon/radeon_object.c
index 37c8ab3ec0f..6a10d22732b 100644
--- a/sys/dev/pci/drm/radeon/radeon_object.c
+++ b/sys/dev/pci/drm/radeon/radeon_object.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radeon_object.c,v 1.4 2014/07/06 08:16:36 jsg Exp $ */
+/* $OpenBSD: radeon_object.c,v 1.5 2015/02/10 01:39:32 jsg Exp $ */
/*
* Copyright 2009 Jerome Glisse.
* All Rights Reserved.
@@ -311,7 +311,7 @@ void radeon_bo_force_delete(struct radeon_device *rdev)
}
DRM_ERROR("Userspace still has active objects !\n");
list_for_each_entry_safe(bo, n, &rdev->gem.objects, list) {
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
#ifdef notyet
DRM_ERROR("%p %p %lu %lu force free\n",
&bo->gem_base, bo, (unsigned long)bo->gem_base.size,
@@ -322,7 +322,7 @@ void radeon_bo_force_delete(struct radeon_device *rdev)
rw_exit_write(&bo->rdev->gem.rwlock);
/* this should unref the ttm bo */
drm_gem_object_unreference(&bo->gem_base);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
}
diff --git a/sys/dev/pci/drm/radeon/radeon_pm.c b/sys/dev/pci/drm/radeon/radeon_pm.c
index e83300114f7..d411ce29fea 100644
--- a/sys/dev/pci/drm/radeon/radeon_pm.c
+++ b/sys/dev/pci/drm/radeon/radeon_pm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radeon_pm.c,v 1.8 2015/01/27 03:17:36 dlg Exp $ */
+/* $OpenBSD: radeon_pm.c,v 1.9 2015/02/10 01:39:32 jsg Exp $ */
/*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -264,7 +264,7 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev)
(rdev->pm.requested_power_state_index == rdev->pm.current_power_state_index))
return;
- DRM_LOCK();
+ mutex_lock(&dev->struct_mutex);
rw_enter_write(&rdev->pm.mclk_lock);
rw_enter_write(&rdev->ring_lock);
@@ -279,7 +279,7 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev)
/* needs a GPU reset dont reset here */
rw_exit_write(&rdev->ring_lock);
rw_exit_write(&rdev->pm.mclk_lock);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
return;
}
}
@@ -315,7 +315,7 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev)
rw_exit_write(&rdev->ring_lock);
rw_exit_write(&rdev->pm.mclk_lock);
- DRM_UNLOCK();
+ mutex_unlock(&dev->struct_mutex);
}
static void radeon_pm_print_states(struct radeon_device *rdev)