提交 5ed0bdf2 编写于 作者: T Thomas Gleixner 提交者: John Stultz

drm: i915: Use nsec based interfaces

Use ktime_get_raw_ns() and get rid of the back and forth timespec
conversions.
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Acked-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
上级 f519b1a2
...@@ -931,7 +931,7 @@ struct intel_ilk_power_mgmt { ...@@ -931,7 +931,7 @@ struct intel_ilk_power_mgmt {
unsigned long last_time1; unsigned long last_time1;
unsigned long chipset_power; unsigned long chipset_power;
u64 last_count2; u64 last_count2;
struct timespec last_time2; u64 last_time2;
unsigned long gfx_power; unsigned long gfx_power;
u8 corr; u8 corr;
......
...@@ -1149,16 +1149,16 @@ static bool can_wait_boost(struct drm_i915_file_private *file_priv) ...@@ -1149,16 +1149,16 @@ static bool can_wait_boost(struct drm_i915_file_private *file_priv)
static int __wait_seqno(struct intel_engine_cs *ring, u32 seqno, static int __wait_seqno(struct intel_engine_cs *ring, u32 seqno,
unsigned reset_counter, unsigned reset_counter,
bool interruptible, bool interruptible,
struct timespec *timeout, s64 *timeout,
struct drm_i915_file_private *file_priv) struct drm_i915_file_private *file_priv)
{ {
struct drm_device *dev = ring->dev; struct drm_device *dev = ring->dev;
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
const bool irq_test_in_progress = const bool irq_test_in_progress =
ACCESS_ONCE(dev_priv->gpu_error.test_irq_rings) & intel_ring_flag(ring); ACCESS_ONCE(dev_priv->gpu_error.test_irq_rings) & intel_ring_flag(ring);
struct timespec before, now;
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
unsigned long timeout_expire; unsigned long timeout_expire;
s64 before, now;
int ret; int ret;
WARN(dev_priv->pm.irqs_disabled, "IRQs disabled\n"); WARN(dev_priv->pm.irqs_disabled, "IRQs disabled\n");
...@@ -1166,7 +1166,7 @@ static int __wait_seqno(struct intel_engine_cs *ring, u32 seqno, ...@@ -1166,7 +1166,7 @@ static int __wait_seqno(struct intel_engine_cs *ring, u32 seqno,
if (i915_seqno_passed(ring->get_seqno(ring, true), seqno)) if (i915_seqno_passed(ring->get_seqno(ring, true), seqno))
return 0; return 0;
timeout_expire = timeout ? jiffies + timespec_to_jiffies_timeout(timeout) : 0; timeout_expire = timeout ? jiffies + nsecs_to_jiffies((u64)*timeout) : 0;
if (INTEL_INFO(dev)->gen >= 6 && can_wait_boost(file_priv)) { if (INTEL_INFO(dev)->gen >= 6 && can_wait_boost(file_priv)) {
gen6_rps_boost(dev_priv); gen6_rps_boost(dev_priv);
...@@ -1181,7 +1181,7 @@ static int __wait_seqno(struct intel_engine_cs *ring, u32 seqno, ...@@ -1181,7 +1181,7 @@ static int __wait_seqno(struct intel_engine_cs *ring, u32 seqno,
/* Record current time in case interrupted by signal, or wedged */ /* Record current time in case interrupted by signal, or wedged */
trace_i915_gem_request_wait_begin(ring, seqno); trace_i915_gem_request_wait_begin(ring, seqno);
getrawmonotonic(&before); before = ktime_get_raw_ns();
for (;;) { for (;;) {
struct timer_list timer; struct timer_list timer;
...@@ -1230,7 +1230,7 @@ static int __wait_seqno(struct intel_engine_cs *ring, u32 seqno, ...@@ -1230,7 +1230,7 @@ static int __wait_seqno(struct intel_engine_cs *ring, u32 seqno,
destroy_timer_on_stack(&timer); destroy_timer_on_stack(&timer);
} }
} }
getrawmonotonic(&now); now = ktime_get_raw_ns();
trace_i915_gem_request_wait_end(ring, seqno); trace_i915_gem_request_wait_end(ring, seqno);
if (!irq_test_in_progress) if (!irq_test_in_progress)
...@@ -1239,10 +1239,9 @@ static int __wait_seqno(struct intel_engine_cs *ring, u32 seqno, ...@@ -1239,10 +1239,9 @@ static int __wait_seqno(struct intel_engine_cs *ring, u32 seqno,
finish_wait(&ring->irq_queue, &wait); finish_wait(&ring->irq_queue, &wait);
if (timeout) { if (timeout) {
struct timespec sleep_time = timespec_sub(now, before); s64 tres = *timeout - (now - before);
*timeout = timespec_sub(*timeout, sleep_time);
if (!timespec_valid(timeout)) /* i.e. negative time remains */ *timeout = tres < 0 ? 0 : tres;
set_normalized_timespec(timeout, 0, 0);
} }
return ret; return ret;
...@@ -2753,16 +2752,10 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file) ...@@ -2753,16 +2752,10 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
struct drm_i915_gem_wait *args = data; struct drm_i915_gem_wait *args = data;
struct drm_i915_gem_object *obj; struct drm_i915_gem_object *obj;
struct intel_engine_cs *ring = NULL; struct intel_engine_cs *ring = NULL;
struct timespec timeout_stack, *timeout = NULL;
unsigned reset_counter; unsigned reset_counter;
u32 seqno = 0; u32 seqno = 0;
int ret = 0; int ret = 0;
if (args->timeout_ns >= 0) {
timeout_stack = ns_to_timespec(args->timeout_ns);
timeout = &timeout_stack;
}
ret = i915_mutex_lock_interruptible(dev); ret = i915_mutex_lock_interruptible(dev);
if (ret) if (ret)
return ret; return ret;
...@@ -2787,9 +2780,9 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file) ...@@ -2787,9 +2780,9 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
goto out; goto out;
/* Do this after OLR check to make sure we make forward progress polling /* Do this after OLR check to make sure we make forward progress polling
* on this IOCTL with a 0 timeout (like busy ioctl) * on this IOCTL with a timeout <=0 (like busy ioctl)
*/ */
if (!args->timeout_ns) { if (args->timeout_ns <= 0) {
ret = -ETIME; ret = -ETIME;
goto out; goto out;
} }
...@@ -2798,10 +2791,8 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file) ...@@ -2798,10 +2791,8 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
reset_counter = atomic_read(&dev_priv->gpu_error.reset_counter); reset_counter = atomic_read(&dev_priv->gpu_error.reset_counter);
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
ret = __wait_seqno(ring, seqno, reset_counter, true, timeout, file->driver_priv); return __wait_seqno(ring, seqno, reset_counter, true, &args->timeout_ns,
if (timeout) file->driver_priv);
args->timeout_ns = timespec_to_ns(timeout);
return ret;
out: out:
drm_gem_object_unreference(&obj->base); drm_gem_object_unreference(&obj->base);
......
...@@ -2993,7 +2993,7 @@ static void ironlake_enable_drps(struct drm_device *dev) ...@@ -2993,7 +2993,7 @@ static void ironlake_enable_drps(struct drm_device *dev)
I915_READ(0x112e0); I915_READ(0x112e0);
dev_priv->ips.last_time1 = jiffies_to_msecs(jiffies); dev_priv->ips.last_time1 = jiffies_to_msecs(jiffies);
dev_priv->ips.last_count2 = I915_READ(0x112f4); dev_priv->ips.last_count2 = I915_READ(0x112f4);
getrawmonotonic(&dev_priv->ips.last_time2); dev_priv->ips.last_time2 = ktime_get_raw_ns();
spin_unlock_irq(&mchdev_lock); spin_unlock_irq(&mchdev_lock);
} }
...@@ -4314,18 +4314,16 @@ static u16 pvid_to_extvid(struct drm_i915_private *dev_priv, u8 pxvid) ...@@ -4314,18 +4314,16 @@ static u16 pvid_to_extvid(struct drm_i915_private *dev_priv, u8 pxvid)
static void __i915_update_gfx_val(struct drm_i915_private *dev_priv) static void __i915_update_gfx_val(struct drm_i915_private *dev_priv)
{ {
struct timespec now, diff1; u64 now, diff, diffms;
u64 diff;
unsigned long diffms;
u32 count; u32 count;
assert_spin_locked(&mchdev_lock); assert_spin_locked(&mchdev_lock);
getrawmonotonic(&now); now = ktime_get_raw_ns();
diff1 = timespec_sub(now, dev_priv->ips.last_time2); diffms = now - dev_priv->ips.last_time2;
do_div(diffms, NSEC_PER_MSEC);
/* Don't divide by 0 */ /* Don't divide by 0 */
diffms = diff1.tv_sec * 1000 + diff1.tv_nsec / 1000000;
if (!diffms) if (!diffms)
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册