Add a few missing trace functions, and "use" them. Add back the WATCH_GTT
authorkettenis <kettenis@openbsd.org>
Sun, 12 Apr 2015 17:10:07 +0000 (17:10 +0000)
committerkettenis <kettenis@openbsd.org>
Sun, 12 Apr 2015 17:10:07 +0000 (17:10 +0000)
code (that isn't actually compiled in).  Use dev_priv->dev in one more place
now that we have it, and add set_normalized_timespec() and use it.

sys/dev/pci/drm/drm_linux.h
sys/dev/pci/drm/i915/i915_gem.c
sys/dev/pci/drm/i915/i915_gem_execbuffer.c
sys/dev/pci/drm/i915/i915_irq.c
sys/dev/pci/drm/i915/i915_trace.h
sys/dev/pci/drm/i915/intel_display.c
sys/dev/pci/drm/i915/intel_ringbuffer.c

index 66e89ba..a859b1e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: drm_linux.h,v 1.23 2015/04/12 12:14:30 jsg Exp $      */
+/*     $OpenBSD: drm_linux.h,v 1.24 2015/04/12 17:10:07 kettenis Exp $ */
 /*
  * Copyright (c) 2013, 2014 Mark Kettenis
  *
@@ -265,6 +265,18 @@ extern struct timeval ns_to_timeval(const int64_t);
 #define time_after(a,b)                ((long)(b) - (long)(a) < 0)
 #define time_after_eq(a,b)     ((long)(b) - (long)(a) <= 0)
 
+static inline void
+set_normalized_timespec(struct timespec *ts, time_t sec, int64_t nsec)
+{
+       while (nsec > NSEC_PER_SEC) {
+               nsec -= NSEC_PER_SEC;
+               sec++;
+       }
+
+       ts->tv_sec = sec;
+       ts->tv_nsec = nsec;
+}
+
 static inline int64_t
 timespec_to_ns(const struct timespec *ts)
 {
index 9e47773..0cbb68e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: i915_gem.c,v 1.90 2015/04/12 03:54:10 jsg Exp $       */
+/*     $OpenBSD: i915_gem.c,v 1.91 2015/04/12 17:10:07 kettenis Exp $  */
 /*
  * Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
  *
@@ -1126,7 +1126,7 @@ static int __wait_seqno(struct intel_ring_buffer *ring, u32 seqno,
                return (int)end;
        case 0: /* Timeout */
                if (timeout)
-                       timeout->tv_sec = timeout->tv_nsec = 0;
+                       set_normalized_timespec(timeout, 0, 0);
                return -ETIME;
        default: /* Completed */
                WARN_ON(end < 0); /* We're not aware of other errors */
@@ -2216,7 +2216,7 @@ i915_add_request(struct intel_ring_buffer *ring,
                }
                if (was_empty) {
                        timeout_add_sec(&dev_priv->mm.retire_timer, 1);
-                       intel_mark_busy(ring->dev);
+                       intel_mark_busy(dev_priv->dev);
                }
        }
 
@@ -3016,6 +3016,42 @@ static bool i915_gem_valid_gtt_space(struct drm_device *dev,
 
 static void i915_gem_verify_gtt(struct drm_device *dev)
 {
+#if WATCH_GTT
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       struct drm_i915_gem_object *obj;
+       int err = 0;
+
+       list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) {
+               if (obj->gtt_space == NULL) {
+                       printk(KERN_ERR "object found on GTT list with no space reserved\n");
+                       err++;
+                       continue;
+               }
+
+               if (obj->cache_level != obj->gtt_space->color) {
+                       printk(KERN_ERR "object reserved space [%08lx, %08lx] with wrong color, cache_level=%x, color=%lx\n",
+                              obj->gtt_space->start,
+                              obj->gtt_space->start + obj->gtt_space->size,
+                              obj->cache_level,
+                              obj->gtt_space->color);
+                       err++;
+                       continue;
+               }
+
+               if (!i915_gem_valid_gtt_space(dev,
+                                             obj->gtt_space,
+                                             obj->cache_level)) {
+                       printk(KERN_ERR "invalid GTT space found at [%08lx, %08lx] - color=%x\n",
+                              obj->gtt_space->start,
+                              obj->gtt_space->start + obj->gtt_space->size,
+                              obj->cache_level);
+                       err++;
+                       continue;
+               }
+       }
+
+       WARN_ON(err);
+#endif
 }
 
 /**
@@ -3907,6 +3943,8 @@ void i915_gem_free_object(struct drm_gem_object *gem_obj)
        struct drm_device *dev = obj->base.dev;
        drm_i915_private_t *dev_priv = dev->dev_private;
 
+       trace_i915_gem_object_destroy(obj);
+
        if (obj->phys_obj)
                i915_gem_detach_phys_object(dev, obj);
 
index 0123ae7..60a283a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: i915_gem_execbuffer.c,v 1.37 2015/04/11 04:36:10 jsg Exp $    */
+/*     $OpenBSD: i915_gem_execbuffer.c,v 1.38 2015/04/12 17:10:07 kettenis Exp $       */
 /*
  * Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org>
  *
@@ -1093,9 +1093,9 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
                        goto err;
 #ifdef __linux__
        }
+#endif
 
        trace_i915_gem_ring_dispatch(ring, intel_ring_get_seqno(ring), flags);
-#endif
 
        i915_gem_execbuffer_move_to_active(&objects, ring);
        i915_gem_execbuffer_retire_commands(dev, file, ring);
index 725d871..8beb31c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: i915_irq.c,v 1.24 2015/04/11 14:39:37 jsg Exp $       */
+/*     $OpenBSD: i915_irq.c,v 1.25 2015/04/12 17:10:07 kettenis Exp $  */
 /* i915_irq.c -- IRQ support for the I915 -*- linux-c -*-
  */
 /*
@@ -32,6 +32,7 @@
 #include <dev/pci/drm/drmP.h>
 #include <dev/pci/drm/i915_drm.h>
 #include "i915_drv.h"
+#include "i915_trace.h"
 #include "intel_drv.h"
 
 /* For display hotplug interrupt */
@@ -347,7 +348,7 @@ static void notify_ring(struct drm_device *dev,
        if (ring->obj == NULL)
                return;
 
-//     trace_i915_gem_request_complete(ring, ring->get_seqno(ring, false));
+       trace_i915_gem_request_complete(ring, ring->get_seqno(ring, false));
 
        wake_up_all(ring);
        if (i915_enable_hangcheck) {
index 67cb004..1bffe65 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: i915_trace.h,v 1.10 2013/12/15 11:42:10 kettenis Exp $        */
+/*     $OpenBSD: i915_trace.h,v 1.11 2015/04/12 17:10:07 kettenis Exp $        */
 /*
  * Copyright (c) 2013 Mark Kettenis <kettenis@openbsd.org>
  *
@@ -20,11 +20,21 @@ trace_i915_gem_object_create(struct drm_i915_gem_object *obj)
 {
 }
 
+static inline void
+trace_i915_gem_object_destroy(struct drm_i915_gem_object *obj)
+{
+}
+
 static inline void
 trace_i915_gem_request_add(struct intel_ring_buffer *ring, u32 seqno)
 {
 }
 
+static inline void
+trace_i915_gem_request_complete(struct intel_ring_buffer *ring, u32 seqno)
+{
+}
+
 static inline void
 trace_i915_gem_request_retire(struct intel_ring_buffer *ring, u32 seqno)
 {
@@ -40,6 +50,26 @@ trace_i915_gem_request_wait_end(struct intel_ring_buffer *ring, u32 seqno)
 {
 }
 
+static inline void
+trace_i915_ring_wait_begin(struct intel_ring_buffer *ring)
+{
+}
+
+static inline void
+trace_i915_ring_wait_end(struct intel_ring_buffer *ring)
+{
+}
+
+static inline void
+trace_i915_flip_request(int plane, struct drm_i915_gem_object *obj)
+{
+}
+
+static inline void
+trace_i915_flip_complete(int plane, struct drm_i915_gem_object *obj)
+{
+}
+
 static inline void
 trace_i915_gem_object_change_domain(struct drm_i915_gem_object *obj,
                                    u32 old_read, u32 old_write)
@@ -82,3 +112,15 @@ static inline void
 trace_i915_gem_evict_everything(struct drm_device *dev)
 {
 }
+
+static inline void
+trace_i915_gem_ring_dispatch(struct intel_ring_buffer *ring, u32 seqno,
+                            u32 flags)
+{
+}
+
+static inline void
+trace_i915_gem_ring_flush(struct intel_ring_buffer *ring, u32 invalidate,
+                            u32 flush)
+{
+}
index 5bd24f2..cafd383 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: intel_display.c,v 1.48 2015/04/12 11:26:54 jsg Exp $  */
+/*     $OpenBSD: intel_display.c,v 1.49 2015/04/12 17:10:07 kettenis Exp $     */
 /*
  * Copyright © 2006-2007 Intel Corporation
  *
@@ -30,6 +30,7 @@
 #include "intel_drv.h"
 #include <dev/pci/drm/i915_drm.h>
 #include "i915_drv.h"
+#include "i915_trace.h"
 #include <dev/pci/drm/drm_dp_helper.h>
 #include <dev/pci/drm/drm_crtc_helper.h>
 
@@ -7129,7 +7130,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
 
        task_add(systq, &work->task);
 
-//     trace_i915_flip_complete(intel_crtc->plane, work->pending_flip_obj);
+       trace_i915_flip_complete(intel_crtc->plane, work->pending_flip_obj);
 }
 
 void intel_finish_page_flip(struct drm_device *dev, int pipe)
@@ -7514,7 +7515,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
        intel_mark_fb_busy(obj);
        mutex_unlock(&dev->struct_mutex);
 
-//     trace_i915_flip_request(intel_crtc->plane, obj);
+       trace_i915_flip_request(intel_crtc->plane, obj);
 
        return 0;
 
index 501f015..0311faa 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: intel_ringbuffer.c,v 1.27 2015/04/12 11:26:54 jsg Exp $       */
+/*     $OpenBSD: intel_ringbuffer.c,v 1.28 2015/04/12 17:10:07 kettenis Exp $  */
 /*
  * Copyright © 2008-2010 Intel Corporation
  *
@@ -31,6 +31,7 @@
 #include <dev/pci/drm/drmP.h>
 #include "i915_drv.h"
 #include <dev/pci/drm/i915_drm.h>
+#include "i915_trace.h"
 #include "intel_drv.h"
 
 /*
@@ -1362,7 +1363,7 @@ static int ring_wait_for_space(struct intel_ring_buffer *ring, int n)
        if (ret != -ENOSPC)
                return ret;
 
-//     trace_i915_ring_wait_begin(ring);
+       trace_i915_ring_wait_begin(ring);
        /* With GEM the hangcheck timer should kick us out of the loop,
         * leaving it early runs the risk of corrupting GEM state (due
         * to running on almost untested codepaths). But on resume
@@ -1374,7 +1375,7 @@ static int ring_wait_for_space(struct intel_ring_buffer *ring, int n)
                ring->head = I915_READ_HEAD(ring);
                ring->space = ring_space(ring);
                if (ring->space >= n) {
-//                     trace_i915_ring_wait_end(ring);
+                       trace_i915_ring_wait_end(ring);
                        return 0;
                }
 
@@ -1392,7 +1393,7 @@ static int ring_wait_for_space(struct intel_ring_buffer *ring, int n)
                if (ret)
                        return ret;
        } while (!time_after(ticks, end));
-//     trace_i915_ring_wait_end(ring);
+       trace_i915_ring_wait_end(ring);
        return -EBUSY;
 }
 
@@ -1884,7 +1885,7 @@ intel_ring_flush_all_caches(struct intel_ring_buffer *ring)
        if (ret)
                return ret;
 
-//     trace_i915_gem_ring_flush(ring, 0, I915_GEM_GPU_DOMAINS);
+       trace_i915_gem_ring_flush(ring, 0, I915_GEM_GPU_DOMAINS);
 
        ring->gpu_caches_dirty = false;
        return 0;
@@ -1904,7 +1905,7 @@ intel_ring_invalidate_all_caches(struct intel_ring_buffer *ring)
        if (ret)
                return ret;
 
-//     trace_i915_gem_ring_flush(ring, I915_GEM_GPU_DOMAINS, flush_domains);
+       trace_i915_gem_ring_flush(ring, I915_GEM_GPU_DOMAINS, flush_domains);
 
        ring->gpu_caches_dirty = false;
        return 0;