From d91f6149b68e83b07a138caf364b545255828b73 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Sun, 12 Apr 2015 17:10:08 +0000 Subject: Add a few missing trace functions, and "use" them. Add back the WATCH_GTT 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 | 14 +++++++++- sys/dev/pci/drm/i915/i915_gem.c | 44 ++++++++++++++++++++++++++++-- sys/dev/pci/drm/i915/i915_gem_execbuffer.c | 4 +-- sys/dev/pci/drm/i915/i915_irq.c | 5 ++-- sys/dev/pci/drm/i915/i915_trace.h | 44 +++++++++++++++++++++++++++++- sys/dev/pci/drm/i915/intel_display.c | 7 +++-- sys/dev/pci/drm/i915/intel_ringbuffer.c | 13 +++++---- 7 files changed, 113 insertions(+), 18 deletions(-) (limited to 'sys/dev/pci/drm') diff --git a/sys/dev/pci/drm/drm_linux.h b/sys/dev/pci/drm/drm_linux.h index 66e89bad939..a859b1ec20f 100644 --- a/sys/dev/pci/drm/drm_linux.h +++ b/sys/dev/pci/drm/drm_linux.h @@ -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) { diff --git a/sys/dev/pci/drm/i915/i915_gem.c b/sys/dev/pci/drm/i915/i915_gem.c index 9e477732953..0cbb68ed14d 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.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 * @@ -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); diff --git a/sys/dev/pci/drm/i915/i915_gem_execbuffer.c b/sys/dev/pci/drm/i915/i915_gem_execbuffer.c index 0123ae7a7ba..60a283af52f 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.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 * @@ -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); diff --git a/sys/dev/pci/drm/i915/i915_irq.c b/sys/dev/pci/drm/i915/i915_irq.c index 725d871ac30..8beb31cf362 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.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 #include #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) { diff --git a/sys/dev/pci/drm/i915/i915_trace.h b/sys/dev/pci/drm/i915/i915_trace.h index 67cb00404f9..1bffe656e48 100644 --- a/sys/dev/pci/drm/i915/i915_trace.h +++ b/sys/dev/pci/drm/i915/i915_trace.h @@ -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 * @@ -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) +{ +} diff --git a/sys/dev/pci/drm/i915/intel_display.c b/sys/dev/pci/drm/i915/intel_display.c index 5bd24f29742..cafd3832228 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.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 #include "i915_drv.h" +#include "i915_trace.h" #include #include @@ -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; diff --git a/sys/dev/pci/drm/i915/intel_ringbuffer.c b/sys/dev/pci/drm/i915/intel_ringbuffer.c index 501f0152832..0311faa83b0 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.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 #include "i915_drv.h" #include +#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; -- cgit v1.2.3