summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2013-04-17 20:04:06 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2013-04-17 20:04:06 +0000
commit4f4dbb41c82e876ba575a45a4236adff86b281ec (patch)
tree486daf147a33266c4e34f145d8d4b342a631df7e /sys/dev
parent157b6d8e95b98c322d0167bbbf7213f7b641e4d9 (diff)
Another round of reducing diffs with Linux code.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/drm/i915/i915_dma.c8
-rw-r--r--sys/dev/pci/drm/i915/i915_drv.c10
-rw-r--r--sys/dev/pci/drm/i915/i915_drv.h16
-rw-r--r--sys/dev/pci/drm/i915/i915_gem.c176
-rw-r--r--sys/dev/pci/drm/i915/i915_gem_evict.c15
-rw-r--r--sys/dev/pci/drm/i915/i915_gem_execbuffer.c18
-rw-r--r--sys/dev/pci/drm/i915/i915_irq.c20
-rw-r--r--sys/dev/pci/drm/i915/intel_display.c12
-rw-r--r--sys/dev/pci/drm/i915/intel_overlay.c18
-rw-r--r--sys/dev/pci/drm/i915/intel_pm.c4
-rw-r--r--sys/dev/pci/drm/i915/intel_ringbuffer.c10
11 files changed, 155 insertions, 152 deletions
diff --git a/sys/dev/pci/drm/i915/i915_dma.c b/sys/dev/pci/drm/i915/i915_dma.c
index b25576c3735..21407ed502c 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.6 2013/03/28 23:19:26 jsg Exp $ */
+/* $OpenBSD: i915_dma.c,v 1.7 2013/04/17 20:04:04 kettenis Exp $ */
/* i915_dma.c -- DMA support for the I915 -*- linux-c -*-
*/
/*
@@ -94,10 +94,10 @@ i915_getparam(struct inteldrm_softc *dev_priv, void *data)
value = 1;
break;
case I915_PARAM_HAS_BSD:
- value = intel_ring_initialized(&dev_priv->rings[VCS]);
+ value = intel_ring_initialized(&dev_priv->ring[VCS]);
break;
case I915_PARAM_HAS_BLT:
- value = intel_ring_initialized(&dev_priv->rings[BCS]);
+ value = intel_ring_initialized(&dev_priv->ring[BCS]);
break;
case I915_PARAM_HAS_RELAXED_FENCING:
#ifdef notyet
@@ -366,7 +366,7 @@ i915_driver_lastclose(struct drm_device *dev)
return;
}
- ret = i915_gem_idle(dev_priv);
+ ret = i915_gem_idle(dev);
if (ret)
DRM_ERROR("failed to idle hardware: %d\n", ret);
diff --git a/sys/dev/pci/drm/i915/i915_drv.c b/sys/dev/pci/drm/i915/i915_drv.c
index 6683df9ea51..c0b269d4e17 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.18 2013/04/14 19:04:37 kettenis Exp $ */
+/* $OpenBSD: i915_drv.c,v 1.19 2013/04/17 20:04:04 kettenis Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -524,10 +524,10 @@ i915_drm_freeze(struct drm_device *dev)
/* If KMS is active, we do the leavevt stuff here */
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
- int error = i915_gem_idle(dev_priv);
+ int error = i915_gem_idle(dev);
if (error) {
printf("GEM idle failed, resume might fail\n");
- return (error);
+ return error;
}
timeout_del(&dev_priv->rps.delayed_resume_to);
@@ -883,7 +883,7 @@ inteldrm_attach(struct device *parent, struct device *self, void *aux)
INIT_LIST_HEAD(&dev_priv->mm.bound_list);
INIT_LIST_HEAD(&dev_priv->mm.fence_list);
for (i = 0; i < I915_NUM_RINGS; i++)
- init_ring_lists(&dev_priv->rings[i]);
+ init_ring_lists(&dev_priv->ring[i]);
timeout_set(&dev_priv->mm.retire_timer, inteldrm_timeout, dev_priv);
timeout_set(&dev_priv->hangcheck_timer, i915_hangcheck_elapsed, dev_priv);
dev_priv->next_seqno = 1;
@@ -1595,7 +1595,7 @@ inteldrm_quiesce(struct inteldrm_softc *dev_priv)
* sure that everything is unbound.
*/
KASSERT(dev_priv->mm.suspended);
- KASSERT(dev_priv->rings[RCS].obj == NULL);
+ KASSERT(dev_priv->ring[RCS].obj == NULL);
atomic_setbits_int(&dev_priv->sc_flags, INTELDRM_QUIET);
while (dev_priv->entries)
tsleep(&dev_priv->entries, 0, "intelquiet", 0);
diff --git a/sys/dev/pci/drm/i915/i915_drv.h b/sys/dev/pci/drm/i915/i915_drv.h
index bf35b7d46a7..6e526b8bccd 100644
--- a/sys/dev/pci/drm/i915/i915_drv.h
+++ b/sys/dev/pci/drm/i915/i915_drv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_drv.h,v 1.13 2013/04/14 19:04:37 kettenis Exp $ */
+/* $OpenBSD: i915_drv.h,v 1.14 2013/04/17 20:04:04 kettenis Exp $ */
/* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
*/
/*
@@ -527,7 +527,7 @@ struct inteldrm_softc {
struct mutex gt_lock;
drm_i915_sarea_t *sarea_priv;
- struct intel_ring_buffer rings[I915_NUM_RINGS];
+ struct intel_ring_buffer ring[I915_NUM_RINGS];
uint32_t next_seqno;
struct drm_dmamem *status_page_dmah;
@@ -796,7 +796,7 @@ typedef struct inteldrm_softc drm_i915_private_t;
/* Iterate over initialised rings */
#define for_each_ring(ring__, dev_priv__, i__) \
for ((i__) = 0; (i__) < I915_NUM_RINGS; (i__)++) \
- if (((ring__) = &(dev_priv__)->rings[(i__)]), intel_ring_initialized((ring__)))
+ if (((ring__) = &(dev_priv__)->ring[(i__)]), intel_ring_initialized((ring__)))
enum hdmi_force_audio {
HDMI_AUDIO_OFF_DVI = -2, /* no aux data for HDMI-DVI converter */
@@ -1059,14 +1059,13 @@ int i915_gem_init_object(struct drm_obj *);
void i915_gem_free_object(struct drm_obj *);
int i915_gem_object_pin(struct drm_i915_gem_object *, uint32_t, bool);
void i915_gem_object_unpin(struct drm_i915_gem_object *);
-void i915_gem_retire_request(struct inteldrm_softc *,
- struct drm_i915_gem_request *);
+void i915_gem_retire_requests(struct drm_device *);
void i915_gem_retire_requests_ring(struct intel_ring_buffer *);
int i915_gem_check_wedge(struct inteldrm_softc *,
bool interruptible);
void i915_gem_retire_work_handler(void *, void*);
-int i915_gem_idle(struct inteldrm_softc *);
+int i915_gem_idle(struct drm_device *);
void i915_gem_object_move_to_active(struct drm_i915_gem_object *,
struct intel_ring_buffer *);
void i915_gem_object_move_to_inactive(struct drm_i915_gem_object *);
@@ -1133,7 +1132,6 @@ void inteldrm_verify_inactive(struct inteldrm_softc *, char *, int);
#define inteldrm_verify_inactive(dev,file,line)
#endif
-void i915_gem_retire_requests(struct inteldrm_softc *);
int i915_gem_object_unbind(struct drm_i915_gem_object *);
int i915_wait_seqno(struct intel_ring_buffer *, uint32_t);
#define I915_GEM_GPU_DOMAINS (~(I915_GEM_DOMAIN_CPU | I915_GEM_DOMAIN_GTT))
@@ -1173,7 +1171,7 @@ void inteldrm_timeout(void *);
bool i915_semaphore_is_enabled(struct drm_device *);
/* i915_gem_evict.c */
-int i915_gem_evict_everything(struct inteldrm_softc *);
+int i915_gem_evict_everything(struct drm_device *);
int i915_gem_evict_something(struct inteldrm_softc *, size_t);
int i915_gem_evict_inactive(struct inteldrm_softc *);
@@ -1361,7 +1359,7 @@ read64(struct inteldrm_softc *dev_priv, bus_size_t off)
#define INTELDRM_VPRINTF(fmt, args...)
#endif
-#define LP_RING(d) (&((struct inteldrm_softc *)(d))->rings[RCS])
+#define LP_RING(d) (&((struct inteldrm_softc *)(d))->ring[RCS])
#define BEGIN_LP_RING(n) \
intel_ring_begin(LP_RING(dev_priv), (n))
diff --git a/sys/dev/pci/drm/i915/i915_gem.c b/sys/dev/pci/drm/i915/i915_gem.c
index d6cee90c61f..3ef9eda3668 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.10 2013/04/08 21:32:19 kettenis Exp $ */
+/* $OpenBSD: i915_gem.c,v 1.11 2013/04/17 20:04:04 kettenis Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -158,7 +158,7 @@ i915_gem_object_is_inactive(struct drm_i915_gem_object *obj)
int
i915_gem_init_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
+ struct drm_file *file)
{
struct inteldrm_softc *dev_priv = dev->dev_private;
struct drm_i915_gem_init *args = data;
@@ -216,17 +216,20 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
}
int
-i915_gem_create(struct drm_file *file, struct drm_device *dev, uint64_t size,
- uint32_t *handle_p)
+i915_gem_create(struct drm_file *file,
+ struct drm_device *dev,
+ uint64_t size,
+ uint32_t *handle_p)
{
struct drm_i915_gem_object *obj;
- uint32_t handle;
int ret;
+ u32 handle;
size = round_page(size);
if (size == 0)
return -EINVAL;
+ /* Allocate the new object */
obj = i915_gem_alloc_object(dev, size);
if (obj == NULL)
return -ENOMEM;
@@ -247,7 +250,6 @@ i915_gem_dumb_create(struct drm_file *file,
struct drm_device *dev,
struct drm_mode_create_dumb *args)
{
-
/* have to work out size/pitch and return them */
args->pitch = roundup2(args->width * ((args->bpp + 7) / 8), 64);
args->size = args->pitch * args->height;
@@ -270,7 +272,7 @@ i915_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
*/
int
i915_gem_create_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
+ struct drm_file *file)
{
struct inteldrm_softc *dev_priv = dev->dev_private;
struct drm_i915_gem_create *args = data;
@@ -293,7 +295,7 @@ i915_gem_create_ioctl(struct drm_device *dev, void *data,
return (ENOMEM);
/* we give our reference to the handle */
- ret = drm_handle_create(file_priv, &obj->base, &handle);
+ ret = drm_handle_create(file, &obj->base, &handle);
if (ret == 0)
args->handle = handle;
@@ -386,7 +388,7 @@ out:
*/
int
i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file)
+ struct drm_file *file)
{
struct inteldrm_softc *dev_priv = dev->dev_private;
struct drm_i915_gem_pwrite *args = data;
@@ -595,14 +597,14 @@ i915_gem_object_wait_rendering(struct drm_i915_gem_object *obj,
// i915_gem_object_wait_rendering__nonblocking
/**
- * Called when user space prepares to use an object with the CPU, either through
- * the mmap ioctl's mapping or a GTT mapping.
+ * Called when user space prepares to use an object with the CPU, either
+ * through the mmap ioctl's mapping or a GTT mapping.
*/
int
i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
struct drm_file *file)
{
- struct drm_i915_gem_set_domain*args = data;
+ struct drm_i915_gem_set_domain *args = data;
struct drm_i915_gem_object *obj;
uint32_t read_domains = args->read_domains;
uint32_t write_domain = args->write_domain;
@@ -1159,11 +1161,9 @@ void
i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
struct intel_ring_buffer *ring)
{
- struct drm_device *dev = obj->base.dev;
- struct inteldrm_softc *dev_priv = dev->dev_private;
- u_int32_t seqno;
-
- seqno = intel_ring_get_seqno(ring);
+ struct drm_device *dev = obj->base.dev;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ u32 seqno = intel_ring_get_seqno(ring);
BUG_ON(ring == NULL);
obj->ring = ring;
@@ -1186,7 +1186,7 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
/* Bump MRU to take account of the delayed flush */
if (obj->fence_reg != I915_FENCE_REG_NONE) {
struct drm_i915_fence_reg *reg;
-
+
reg = &dev_priv->fence_regs[obj->fence_reg];
list_move_tail(&reg->lru_list,
&dev_priv->mm.fence_list);
@@ -1261,7 +1261,7 @@ i915_gem_handle_seqno_wrap(struct drm_device *dev)
if (ret)
return ret;
- i915_gem_retire_requests(dev_priv);
+ i915_gem_retire_requests(dev);
for_each_ring(ring, dev_priv, i) {
for (j = 0; j < nitems(ring->sync_seqno); j++)
ring->sync_seqno[j] = 0;
@@ -1288,22 +1288,16 @@ i915_gem_get_seqno(struct drm_device *dev, u32 *seqno)
return 0;
}
-/**
- * Creates a new sequence number, emitting a write of it to the status page
- * plus an interrupt, which will trigger and interrupt if they are currently
- * enabled.
- *
- * Returned sequence numbers are nonzero on success.
- */
int
i915_add_request(struct intel_ring_buffer *ring,
struct drm_file *file,
u32 *out_seqno)
{
- drm_i915_private_t *dev_priv = ring->dev->dev_private;
- struct drm_i915_gem_request *request;
- u32 request_ring_position;
- int was_empty, ret;
+ drm_i915_private_t *dev_priv = ring->dev->dev_private;
+ struct drm_i915_gem_request *request;
+ u32 request_ring_position;
+ int was_empty;
+ int ret;
/*
* Emit any outstanding flushes - execbuf can fail to emit the flush
@@ -1440,10 +1434,11 @@ i915_gem_reset(struct drm_device *dev)
{
drm_i915_private_t *dev_priv = dev->dev_private;
struct drm_i915_gem_object *obj;
+ struct intel_ring_buffer *ring;
int i;
- for (i = 0; i < I915_NUM_RINGS; i++)
- i915_gem_reset_ring_lists(dev_priv, &dev_priv->rings[i]);
+ for_each_ring(ring, dev_priv, i)
+ i915_gem_reset_ring_lists(dev_priv, ring);
/* Move everything out of the GPU domains to ensure we do any
* necessary invalidation upon reuse.
@@ -1513,8 +1508,9 @@ i915_gem_retire_requests_ring(struct intel_ring_buffer *ring)
}
void
-i915_gem_retire_requests(struct inteldrm_softc *dev_priv)
+i915_gem_retire_requests(struct drm_device *dev)
{
+ drm_i915_private_t *dev_priv = dev->dev_private;
struct intel_ring_buffer *ring;
int i;
@@ -1539,9 +1535,9 @@ i915_gem_retire_work_handler(void *arg1, void *unused)
return;
}
- i915_gem_retire_requests(dev_priv);
+ i915_gem_retire_requests(dev);
- /* Send a periodic flush down the ring so we don't hold onto GEM
+ /* Send a periodic flush down the ring so we don't hold onto GEM
* objects indefinitely.
*/
idle = true;
@@ -1656,7 +1652,6 @@ i915_gem_object_finish_gtt(struct drm_i915_gem_object *obj)
#endif
}
-
/**
* Unbinds an object from the GTT aperture.
*
@@ -1665,9 +1660,9 @@ i915_gem_object_finish_gtt(struct drm_i915_gem_object *obj)
int
i915_gem_object_unbind(struct drm_i915_gem_object *obj)
{
- struct drm_device *dev = obj->base.dev;
- struct inteldrm_softc *dev_priv = dev->dev_private;
- int ret = 0;
+ drm_i915_private_t *dev_priv = obj->base.dev->dev_private;
+ struct drm_device *dev = obj->base.dev;
+ int ret = 0;
DRM_ASSERT_HELD(&obj->base);
/*
@@ -2062,7 +2057,8 @@ i915_gem_object_get_fence(struct drm_i915_gem_object *obj)
*/
int
i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj,
- unsigned alignment, bool map_and_fenceable)
+ unsigned alignment,
+ bool map_and_fenceable)
{
struct drm_device *dev = obj->base.dev;
drm_i915_private_t *dev_priv = dev->dev_private;
@@ -2329,7 +2325,7 @@ int
i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
enum i915_cache_level cache_level)
{
-// struct drm_device *dev = obj->base.dev;
+ struct drm_device *dev = obj->base.dev;
// drm_i915_private_t *dev_priv = dev->dev_private;
int ret;
@@ -2352,7 +2348,7 @@ i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
* registers with snooped memory, so relinquish any fences
* currently pointing to our region in the aperture.
*/
- if (INTEL_INFO(obj->base.dev)->gen < 6) {
+ if (INTEL_INFO(dev)->gen < 6) {
ret = i915_gem_object_put_fence(obj);
if (ret)
return ret;
@@ -2460,6 +2456,11 @@ unlock:
return ret;
}
+/*
+ * Prepare buffer for display plane (scanout, cursors, etc).
+ * Can be called from an uninterruptible phase (modesetting) and allows
+ * any flushes to be pipelined (for pageflips).
+ */
int
i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
u32 alignment,
@@ -2534,7 +2535,7 @@ i915_gem_object_finish_gpu(struct drm_i915_gem_object *obj)
* Moves a single object to the CPU read, and possibly write domain.
*
* This function returns when the move is complete, including waiting on
- * flushes to return.
+ * flushes to occur.
*/
int
i915_gem_object_set_to_cpu_domain(struct drm_i915_gem_object *obj, bool write)
@@ -2633,7 +2634,7 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj,
bool map_and_fenceable)
{
struct drm_device *dev = obj->base.dev;
- int ret;
+ int ret;
DRM_ASSERT_HELD(&obj->base);
inteldrm_verify_inactive(dev_priv, __FILE__, __LINE__);
@@ -2699,7 +2700,7 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data,
struct drm_file *file)
{
struct inteldrm_softc *dev_priv = dev->dev_private;
- struct drm_i915_gem_pin *args = data;
+ struct drm_i915_gem_pin *args = data;
struct drm_i915_gem_object *obj;
int ret;
@@ -2721,19 +2722,20 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data,
goto out;
}
- if (++obj->user_pin_count == 1) {
+ if (obj->user_pin_count == 0) {
ret = i915_gem_object_pin(obj, args->alignment, 1);
- if (ret != 0)
+ if (ret)
goto out;
inteldrm_set_max_obj_size(dev_priv);
}
+ obj->user_pin_count++;
+
/* XXX - flush the CPU caches for pinned objects
* as the X server doesn't manage domains yet
*/
i915_gem_object_set_to_gtt_domain(obj, true);
args->offset = obj->gtt_offset;
-
out:
drm_unhold_and_unref(&obj->base);
unlock:
@@ -2746,7 +2748,7 @@ i915_gem_unpin_ioctl(struct drm_device *dev, void *data,
struct drm_file *file)
{
struct inteldrm_softc *dev_priv = dev->dev_private;
- struct drm_i915_gem_pin *args = data;
+ struct drm_i915_gem_pin *args = data;
struct drm_i915_gem_object *obj;
int ret;
@@ -2782,7 +2784,7 @@ unlock:
int
i915_gem_busy_ioctl(struct drm_device *dev, void *data,
- struct drm_file *file)
+ struct drm_file *file)
{
struct drm_i915_gem_busy *args = data;
struct drm_i915_gem_object *obj;
@@ -2846,7 +2848,7 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
if (obj->madv != __I915_MADV_PURGED)
obj->madv = args->madv;
- /* if the object is no longer bound, discard its backing storage */
+ /* if the object is no longer attached, discard its backing storage */
if (i915_gem_object_is_purgeable(obj) && obj->dmamap == NULL)
i915_gem_object_truncate(obj);
@@ -2945,10 +2947,10 @@ i915_gem_free_object(struct drm_obj *gem_obj)
}
int
-i915_gem_idle(struct inteldrm_softc *dev_priv)
+i915_gem_idle(struct drm_device *dev)
{
- struct drm_device *dev = (struct drm_device *)dev_priv->drmdev;
- int ret;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ int ret;
/* If drm attach failed */
if (dev == NULL)
@@ -2966,11 +2968,11 @@ i915_gem_idle(struct inteldrm_softc *dev_priv)
DRM_UNLOCK();
return ret;
}
- i915_gem_retire_requests(dev_priv);
+ i915_gem_retire_requests(dev);
/* Under UMS, be paranoid and evict. */
if (!drm_core_check_feature(dev, DRIVER_MODESET))
- i915_gem_evict_everything(dev_priv);
+ i915_gem_evict_everything(dev);
i915_gem_reset_fences(dev);
@@ -2979,14 +2981,14 @@ i915_gem_idle(struct inteldrm_softc *dev_priv)
* And not confound mm.suspended!
*/
dev_priv->mm.suspended = 1;
- /* if we hung then the timer alredy fired. */
timeout_del(&dev_priv->hangcheck_timer);
i915_kernel_lost_context(dev);
i915_gem_cleanup_ringbuffer(dev);
+
DRM_UNLOCK();
- /* this should be idle now */
+ /* Cancel the retire work handler, which should be idle now. */
timeout_del(&dev_priv->mm.retire_timer);
return 0;
@@ -3082,9 +3084,9 @@ i915_gem_init_hw(struct drm_device *dev)
return 0;
cleanup_bsd_ring:
- intel_cleanup_ring_buffer(&dev_priv->rings[VCS]);
+ intel_cleanup_ring_buffer(&dev_priv->ring[VCS]);
cleanup_render_ring:
- intel_cleanup_ring_buffer(&dev_priv->rings[RCS]);
+ intel_cleanup_ring_buffer(&dev_priv->ring[RCS]);
return ret;
}
@@ -3147,57 +3149,53 @@ int
i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
- struct inteldrm_softc *dev_priv = dev->dev_private;
- struct intel_ring_buffer *ring;
- int ret, i;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ int ret;
if (drm_core_check_feature(dev, DRIVER_MODESET))
- return (0);
-
- /* XXX until we have support for the rings on sandybridge */
- if (IS_GEN6(dev) || IS_GEN7(dev))
- return (0);
+ return 0;
- if (dev_priv->mm.wedged) {
+ if (atomic_read(&dev_priv->mm.wedged)) {
DRM_ERROR("Reenabling wedged hardware, good luck\n");
- dev_priv->mm.wedged = 0;
+ atomic_set(&dev_priv->mm.wedged, 0);
}
-
DRM_LOCK();
dev_priv->mm.suspended = 0;
ret = i915_gem_init_hw(dev);
if (ret != 0) {
DRM_UNLOCK();
- return (ret);
+ return ret;
}
- /* gtt mapping means that the inactive list may not be empty */
- KASSERT(list_empty(&dev_priv->mm.active_list));
- for_each_ring(ring, dev_priv, i)
- KASSERT(list_empty(&ring->request_list));
+ BUG_ON(!list_empty(&dev_priv->mm.active_list));
DRM_UNLOCK();
- drm_irq_install(dev);
+ ret = drm_irq_install(dev);
+ if (ret)
+ goto cleanup_ringbuffer;
- return (0);
+ return 0;
+
+cleanup_ringbuffer:
+ DRM_LOCK();
+ i915_gem_cleanup_ringbuffer(dev);
+ dev_priv->mm.suspended = 1;
+ DRM_UNLOCK();
+
+ return ret;
}
int
i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
- struct inteldrm_softc *dev_priv = dev->dev_private;
- int ret;
-
if (drm_core_check_feature(dev, DRIVER_MODESET))
return 0;
- /* don't unistall if we fail, repeat calls on failure will screw us */
- if ((ret = i915_gem_idle(dev_priv)) == 0)
- drm_irq_uninstall(dev);
- return (ret);
+ drm_irq_uninstall(dev);
+ return i915_gem_idle(dev);
}
// i915_gem_lastclose
@@ -3211,6 +3209,10 @@ init_ring_lists(struct intel_ring_buffer *ring)
// i915_gem_load
+/*
+ * Create a physically contiguous memory object for this object
+ * e.g. for cursor + overlay regs
+ */
int
i915_gem_init_phys_object(struct drm_device *dev,
int id, int size, int align)
@@ -3281,7 +3283,9 @@ void i915_gem_detach_phys_object(struct drm_device *dev,
int
i915_gem_attach_phys_object(struct drm_device *dev,
- struct drm_i915_gem_object *obj, int id, int align)
+ struct drm_i915_gem_object *obj,
+ int id,
+ int align)
{
drm_i915_private_t *dev_priv = dev->dev_private;
int ret = 0;
diff --git a/sys/dev/pci/drm/i915/i915_gem_evict.c b/sys/dev/pci/drm/i915/i915_gem_evict.c
index d3874da96a4..9fda6128715 100644
--- a/sys/dev/pci/drm/i915/i915_gem_evict.c
+++ b/sys/dev/pci/drm/i915/i915_gem_evict.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i915_gem_evict.c,v 1.2 2013/04/03 07:36:57 jsg Exp $ */
+/* $OpenBSD: i915_gem_evict.c,v 1.3 2013/04/17 20:04:04 kettenis Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -98,6 +98,7 @@ i915_gem_find_inactive_object(struct inteldrm_softc *dev_priv,
int
i915_gem_evict_something(struct inteldrm_softc *dev_priv, size_t min_size)
{
+ struct drm_device *dev = (struct drm_device *)dev_priv->drmdev;
struct drm_obj *obj;
struct drm_i915_gem_request *request;
struct drm_i915_gem_object *obj_priv;
@@ -107,7 +108,7 @@ i915_gem_evict_something(struct inteldrm_softc *dev_priv, size_t min_size)
int found;
for (;;) {
- i915_gem_retire_requests(dev_priv);
+ i915_gem_retire_requests(dev);
/* If there's an inactive buffer available now, grab it
* and be done.
@@ -159,16 +160,16 @@ i915_gem_evict_something(struct inteldrm_softc *dev_priv, size_t min_size)
if (!list_empty(&dev_priv->mm.inactive_list))
return (i915_gem_evict_inactive(dev_priv));
else
- return (i915_gem_evict_everything(dev_priv));
+ return (i915_gem_evict_everything(dev));
}
/* NOTREACHED */
}
int
-i915_gem_evict_everything(struct inteldrm_softc *dev_priv)
+i915_gem_evict_everything(struct drm_device *dev)
{
- struct drm_device *dev = (struct drm_device *)dev_priv->drmdev;
- int ret;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ int ret;
if (list_empty(&dev_priv->mm.inactive_list) &&
list_empty(&dev_priv->mm.active_list))
@@ -182,7 +183,7 @@ i915_gem_evict_everything(struct inteldrm_softc *dev_priv)
if (ret)
return ret;
- i915_gem_retire_requests(dev_priv);
+ i915_gem_retire_requests(dev);
i915_gem_evict_inactive(dev_priv);
diff --git a/sys/dev/pci/drm/i915/i915_gem_execbuffer.c b/sys/dev/pci/drm/i915/i915_gem_execbuffer.c
index d977dbacd29..d4a9c3a37cd 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.5 2013/04/03 19:57:17 kettenis Exp $ */
+/* $OpenBSD: i915_gem_execbuffer.c,v 1.6 2013/04/17 20:04:04 kettenis Exp $ */
/*
* Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
*
@@ -258,7 +258,7 @@ err: /* Decrement pin count for bound objects */
if (ret != -ENOSPC || retry++)
return ret;
- ret = i915_gem_evict_everything(ring->dev->dev_private);
+ ret = i915_gem_evict_everything(ring->dev);
if (ret)
return ret;
} while (1);
@@ -392,7 +392,7 @@ i915_reset_gen7_sol_offsets(struct drm_device *dev,
drm_i915_private_t *dev_priv = dev->dev_private;
int ret, i;
- if (!IS_GEN7(dev) || ring != &dev_priv->rings[RCS])
+ if (!IS_GEN7(dev) || ring != &dev_priv->ring[RCS])
return 0;
ret = intel_ring_begin(ring, 4 * 3);
@@ -463,13 +463,13 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
switch (args->flags & I915_EXEC_RING_MASK) {
case I915_EXEC_DEFAULT:
case I915_EXEC_RENDER:
- ring = &dev_priv->rings[RCS];
+ ring = &dev_priv->ring[RCS];
break;
case I915_EXEC_BSD:
- ring = &dev_priv->rings[VCS];
+ ring = &dev_priv->ring[VCS];
break;
case I915_EXEC_BLT:
- ring = &dev_priv->rings[BCS];
+ ring = &dev_priv->ring[BCS];
break;
default:
printf("unknown ring %d\n",
@@ -488,7 +488,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
case I915_EXEC_CONSTANTS_REL_GENERAL:
case I915_EXEC_CONSTANTS_ABSOLUTE:
case I915_EXEC_CONSTANTS_REL_SURFACE:
- if (ring == &dev_priv->rings[RCS] &&
+ if (ring == &dev_priv->ring[RCS] &&
mode != dev_priv->relative_constants_mode) {
if (INTEL_INFO(dev)->gen < 4)
return EINVAL;
@@ -605,7 +605,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
}
pinned = 0;
/* evict everyone we can from the aperture */
- ret = i915_gem_evict_everything(dev_priv);
+ ret = i915_gem_evict_everything(dev);
if (ret)
goto err;
}
@@ -630,7 +630,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
if (ret)
goto err;
- if (ring == &dev_priv->rings[RCS] &&
+ if (ring == &dev_priv->ring[RCS] &&
mode != dev_priv->relative_constants_mode) {
ret = intel_ring_begin(ring, 4);
if (ret)
diff --git a/sys/dev/pci/drm/i915/i915_irq.c b/sys/dev/pci/drm/i915/i915_irq.c
index bb10448020a..467888c344c 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.4 2013/03/28 20:37:50 kettenis Exp $ */
+/* $OpenBSD: i915_irq.c,v 1.5 2013/04/17 20:04:04 kettenis Exp $ */
/* i915_irq.c -- IRQ support for the I915 -*- linux-c -*-
*/
/*
@@ -554,11 +554,11 @@ snb_gt_irq_handler(struct drm_device *dev,
if (gt_iir & (GEN6_RENDER_USER_INTERRUPT |
GEN6_RENDER_PIPE_CONTROL_NOTIFY_INTERRUPT))
- notify_ring(dev, &dev_priv->rings[RCS]);
+ notify_ring(dev, &dev_priv->ring[RCS]);
if (gt_iir & GEN6_BSD_USER_INTERRUPT)
- notify_ring(dev, &dev_priv->rings[VCS]);
+ notify_ring(dev, &dev_priv->ring[VCS]);
if (gt_iir & GEN6_BLITTER_USER_INTERRUPT)
- notify_ring(dev, &dev_priv->rings[BCS]);
+ notify_ring(dev, &dev_priv->ring[BCS]);
if (gt_iir & (GT_GEN6_BLT_CS_ERROR_INTERRUPT |
GT_GEN6_BSD_CS_ERROR_INTERRUPT |
@@ -825,9 +825,9 @@ ilk_gt_irq_handler(struct drm_device *dev,
u32 gt_iir)
{
if (gt_iir & (GT_USER_INTERRUPT | GT_PIPE_NOTIFY))
- notify_ring(dev, &dev_priv->rings[RCS]);
+ notify_ring(dev, &dev_priv->ring[RCS]);
if (gt_iir & GT_BSD_USER_INTERRUPT)
- notify_ring(dev, &dev_priv->rings[VCS]);
+ notify_ring(dev, &dev_priv->ring[VCS]);
}
int
@@ -2310,7 +2310,7 @@ i8xx_intr(void *arg)
// i915_update_dri1_breadcrumb(dev);
if (iir & I915_USER_INTERRUPT)
- notify_ring(dev, &dev_priv->rings[RCS]);
+ notify_ring(dev, &dev_priv->ring[RCS]);
if (pipe_stats[0] & PIPE_VBLANK_INTERRUPT_STATUS &&
drm_handle_vblank(dev, 0)) {
@@ -2507,7 +2507,7 @@ i915_intr(void *arg)
new_iir = I915_READ(IIR); /* Flush posted writes */
if (iir & I915_USER_INTERRUPT)
- notify_ring(dev, &dev_priv->rings[RCS]);
+ notify_ring(dev, &dev_priv->ring[RCS]);
for_each_pipe(pipe) {
int plane = pipe;
@@ -2748,9 +2748,9 @@ i965_intr(void *arg)
new_iir = I915_READ(IIR); /* Flush posted writes */
if (iir & I915_USER_INTERRUPT)
- notify_ring(dev, &dev_priv->rings[RCS]);
+ notify_ring(dev, &dev_priv->ring[RCS]);
if (iir & I915_BSD_USER_INTERRUPT)
- notify_ring(dev, &dev_priv->rings[VCS]);
+ notify_ring(dev, &dev_priv->ring[VCS]);
if (iir & I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT)
intel_prepare_page_flip(dev, 0);
diff --git a/sys/dev/pci/drm/i915/intel_display.c b/sys/dev/pci/drm/i915/intel_display.c
index 7c9141d90d7..3011e1e0b7b 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.4 2013/04/14 04:49:22 jsg Exp $ */
+/* $OpenBSD: intel_display.c,v 1.5 2013/04/17 20:04:04 kettenis Exp $ */
/*
* Copyright © 2006-2007 Intel Corporation
*
@@ -7778,7 +7778,7 @@ intel_gen2_queue_flip(struct drm_device *dev,
struct inteldrm_softc *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
u32 flip_mask;
- struct intel_ring_buffer *ring = &dev_priv->rings[RCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
int ret;
ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
@@ -7823,7 +7823,7 @@ intel_gen3_queue_flip(struct drm_device *dev,
struct inteldrm_softc *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
u32 flip_mask;
- struct intel_ring_buffer *ring = &dev_priv->rings[RCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
int ret;
ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
@@ -7865,7 +7865,7 @@ intel_gen4_queue_flip(struct drm_device *dev,
struct inteldrm_softc *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
uint32_t pf, pipesrc;
- struct intel_ring_buffer *ring = &dev_priv->rings[RCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
int ret;
ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
@@ -7913,7 +7913,7 @@ intel_gen6_queue_flip(struct drm_device *dev,
{
struct inteldrm_softc *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
- struct intel_ring_buffer *ring = &dev_priv->rings[RCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
uint32_t pf, pipesrc;
int ret;
@@ -7964,7 +7964,7 @@ intel_gen7_queue_flip(struct drm_device *dev,
{
struct inteldrm_softc *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
- struct intel_ring_buffer *ring = &dev_priv->rings[BCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[BCS];
uint32_t plane_bit = 0;
int ret;
diff --git a/sys/dev/pci/drm/i915/intel_overlay.c b/sys/dev/pci/drm/i915/intel_overlay.c
index 860162f5476..8751c68fdca 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.2 2013/03/25 06:22:28 jsg Exp $ */
+/* $OpenBSD: intel_overlay.c,v 1.3 2013/04/17 20:04:04 kettenis Exp $ */
/*
* Copyright © 2009
*
@@ -285,7 +285,7 @@ intel_overlay_do_wait_request(struct intel_overlay *overlay,
{
struct drm_device *dev = overlay->dev;
drm_i915_private_t *dev_priv = dev->dev_private;
- struct intel_ring_buffer *ring = &dev_priv->rings[RCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
int ret;
BUG_ON(overlay->last_flip_req);
@@ -297,7 +297,7 @@ intel_overlay_do_wait_request(struct intel_overlay *overlay,
ret = i915_wait_seqno(ring, overlay->last_flip_req);
if (ret)
return ret;
- i915_gem_retire_requests(dev_priv);
+ i915_gem_retire_requests(dev);
overlay->last_flip_req = 0;
return 0;
@@ -309,7 +309,7 @@ intel_overlay_on(struct intel_overlay *overlay)
{
struct drm_device *dev = overlay->dev;
struct inteldrm_softc *dev_priv = dev->dev_private;
- struct intel_ring_buffer *ring = &dev_priv->rings[RCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
int ret;
BUG_ON(overlay->active);
@@ -337,7 +337,7 @@ intel_overlay_continue(struct intel_overlay *overlay,
{
struct drm_device *dev = overlay->dev;
drm_i915_private_t *dev_priv = dev->dev_private;
- struct intel_ring_buffer *ring = &dev_priv->rings[RCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
u32 flip_addr = overlay->flip_addr;
u32 tmp;
int ret;
@@ -397,7 +397,7 @@ intel_overlay_off(struct intel_overlay *overlay)
{
struct drm_device *dev = overlay->dev;
struct inteldrm_softc *dev_priv = dev->dev_private;
- struct intel_ring_buffer *ring = &dev_priv->rings[RCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
u32 flip_addr = overlay->flip_addr;
int ret;
@@ -441,7 +441,7 @@ intel_overlay_recover_from_interrupt(struct intel_overlay *overlay)
{
struct drm_device *dev = overlay->dev;
drm_i915_private_t *dev_priv = dev->dev_private;
- struct intel_ring_buffer *ring = &dev_priv->rings[RCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
int ret;
if (overlay->last_flip_req == 0)
@@ -450,7 +450,7 @@ intel_overlay_recover_from_interrupt(struct intel_overlay *overlay)
ret = i915_wait_seqno(ring, overlay->last_flip_req);
if (ret)
return ret;
- i915_gem_retire_requests(dev_priv);
+ i915_gem_retire_requests(dev);
if (overlay->flip_tail)
overlay->flip_tail(overlay);
@@ -468,7 +468,7 @@ intel_overlay_release_old_vid(struct intel_overlay *overlay)
{
struct drm_device *dev = overlay->dev;
drm_i915_private_t *dev_priv = dev->dev_private;
- struct intel_ring_buffer *ring = &dev_priv->rings[RCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
int ret;
/* Only wait if there is actually an old frame to release to
diff --git a/sys/dev/pci/drm/i915/intel_pm.c b/sys/dev/pci/drm/i915/intel_pm.c
index 134ef34e217..905a2dba2f9 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.3 2013/03/22 01:00:39 jsg Exp $ */
+/* $OpenBSD: intel_pm.c,v 1.4 2013/04/17 20:04:05 kettenis Exp $ */
/*
* Copyright © 2012 Intel Corporation
*
@@ -2968,7 +2968,7 @@ void
ironlake_enable_rc6(struct drm_device *dev)
{
struct inteldrm_softc *dev_priv = dev->dev_private;
- struct intel_ring_buffer *ring = &dev_priv->rings[RCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
bool was_interruptible;
int ret;
diff --git a/sys/dev/pci/drm/i915/intel_ringbuffer.c b/sys/dev/pci/drm/i915/intel_ringbuffer.c
index 18628a76d2d..8f00b626e6e 100644
--- a/sys/dev/pci/drm/i915/intel_ringbuffer.c
+++ b/sys/dev/pci/drm/i915/intel_ringbuffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intel_ringbuffer.c,v 1.1 2013/03/18 12:36:52 jsg Exp $ */
+/* $OpenBSD: intel_ringbuffer.c,v 1.2 2013/04/17 20:04:05 kettenis Exp $ */
/*
* Copyright © 2008-2010 Intel Corporation
*
@@ -1731,7 +1731,7 @@ int
intel_init_render_ring_buffer(struct drm_device *dev)
{
drm_i915_private_t *dev_priv = dev->dev_private;
- struct intel_ring_buffer *ring = &dev_priv->rings[RCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
ring->name = "render ring";
ring->id = RCS;
@@ -1817,7 +1817,7 @@ int
intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
{
drm_i915_private_t *dev_priv = dev->dev_private;
- struct intel_ring_buffer *ring = &dev_priv->rings[RCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
int ret;
ring->name = "render ring";
@@ -1884,7 +1884,7 @@ int
intel_init_bsd_ring_buffer(struct drm_device *dev)
{
drm_i915_private_t *dev_priv = dev->dev_private;
- struct intel_ring_buffer *ring = &dev_priv->rings[VCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[VCS];
ring->name = "bsd ring";
ring->id = VCS;
@@ -1933,7 +1933,7 @@ int
intel_init_blt_ring_buffer(struct drm_device *dev)
{
drm_i915_private_t *dev_priv = dev->dev_private;
- struct intel_ring_buffer *ring = &dev_priv->rings[BCS];
+ struct intel_ring_buffer *ring = &dev_priv->ring[BCS];
ring->name = "blitter ring";
ring->id = BCS;