This is a squash of 16e9a21f33cda9d48b70ff54e1ed2e4a77497bc6 and
5ed0bdf21a85d78e04f89f15ccf227562177cbd9 reverts

--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1125,7 +1125,7 @@ struct intel_ilk_power_mgmt {
 	unsigned long last_time1;
 	unsigned long chipset_power;
 	u64 last_count2;
-	u64 last_time2;
+	struct timespec last_time2;
 	unsigned long gfx_power;
 	u8 corr;
 
@@ -2873,7 +2873,7 @@ int __i915_add_request(struct intel_engi
 int __i915_wait_request(struct drm_i915_gem_request *req,
 			unsigned reset_counter,
 			bool interruptible,
-			s64 *timeout,
+			struct timespec *timeout,
 			struct intel_rps_client *rps);
 int __must_check i915_wait_request(struct drm_i915_gem_request *req);
 int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1222,7 +1222,7 @@ static int __i915_spin_request(struct dr
 int __i915_wait_request(struct drm_i915_gem_request *req,
 			unsigned reset_counter,
 			bool interruptible,
-			s64 *timeout,
+			struct timespec *timeout,
 			struct intel_rps_client *rps)
 {
 	struct intel_engine_cs *ring = i915_gem_request_get_ring(req);
@@ -1230,9 +1230,9 @@ int __i915_wait_request(struct drm_i915_
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	const bool irq_test_in_progress =
 		ACCESS_ONCE(dev_priv->gpu_error.test_irq_rings) & intel_ring_flag(ring);
+	struct timespec before, now;
 	DEFINE_WAIT(wait);
 	unsigned long timeout_expire;
-	s64 before, now;
 	int ret;
 
 	WARN(!intel_irqs_enabled(dev_priv), "IRQs disabled");
@@ -1243,15 +1243,14 @@ int __i915_wait_request(struct drm_i915_
 	if (i915_gem_request_completed(req, true))
 		return 0;
 
-	timeout_expire = timeout ?
-		jiffies + nsecs_to_jiffies_timeout((u64)*timeout) : 0;
+	timeout_expire = timeout ? jiffies + timespec_to_jiffies_timeout(timeout) : 0;
 
 	if (INTEL_INFO(dev_priv)->gen >= 6)
 		gen6_rps_boost(dev_priv, rps, req->emitted_jiffies);
 
 	/* Record current time in case interrupted by signal, or wedged */
 	trace_i915_gem_request_wait_begin(req);
-	before = ktime_get_raw_ns();
+	getrawmonotonic(&before);
 
 	/* Optimistic spin for the next jiffie before touching IRQs */
 	ret = __i915_spin_request(req);
@@ -1317,13 +1316,14 @@ int __i915_wait_request(struct drm_i915_
 	finish_wait(&ring->irq_queue, &wait);
 
 out:
-	now = ktime_get_raw_ns();
+	getrawmonotonic(&now);
 	trace_i915_gem_request_wait_end(req);
 
 	if (timeout) {
-		s64 tres = *timeout - (now - before);
-
-		*timeout = tres < 0 ? 0 : tres;
+		struct timespec sleep_time = timespec_sub(now, before);
+		*timeout = timespec_sub(*timeout, sleep_time);
+		if (!timespec_valid(timeout)) /* i.e. negative time remains */
+			set_normalized_timespec(timeout, 0, 0);
 
 		/*
 		 * Apparently ktime isn't accurate enough and occasionally has a
@@ -3000,10 +3000,16 @@ i915_gem_wait_ioctl(struct drm_device *d
 	struct drm_i915_gem_wait *args = data;
 	struct drm_i915_gem_object *obj;
 	struct drm_i915_gem_request *req[I915_NUM_RINGS];
+	struct timespec timeout_stack, *timeout = NULL;
 	unsigned reset_counter;
 	int i, n = 0;
 	int ret;
 
+	if (args->timeout_ns >= 0) {
+		timeout_stack = ns_to_timespec(args->timeout_ns);
+		timeout = &timeout_stack;
+	}
+
 	if (args->flags != 0)
 		return -EINVAL;
 
@@ -3028,7 +3034,7 @@ i915_gem_wait_ioctl(struct drm_device *d
 	/* Do this after OLR check to make sure we make forward progress polling
 	 * on this IOCTL with a timeout == 0 (like busy ioctl)
 	 */
-	if (args->timeout_ns == 0) {
+	if (!args->timeout_ns) {
 		ret = -ETIME;
 		goto out;
 	}
@@ -3048,8 +3054,10 @@ i915_gem_wait_ioctl(struct drm_device *d
 	for (i = 0; i < n; i++) {
 		if (ret == 0)
 			ret = __i915_wait_request(req[i], reset_counter, true,
-						  args->timeout_ns > 0 ? &args->timeout_ns : NULL,
+						  timeout,
 						  file->driver_priv);
+		if (timeout)
+			args->timeout_ns = timespec_to_ns(timeout);
 		i915_gem_request_unreference__unlocked(req[i]);
 	}
 	return ret;
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -3866,7 +3866,7 @@ static void ironlake_enable_drps(struct
 		I915_READ(0x112e0);
 	dev_priv->ips.last_time1 = jiffies_to_msecs(jiffies);
 	dev_priv->ips.last_count2 = I915_READ(0x112f4);
-	dev_priv->ips.last_time2 = ktime_get_raw_ns();
+	getrawmonotonic(&dev_priv->ips.last_time2);
 
 	spin_unlock_irq(&mchdev_lock);
 }
@@ -5364,14 +5364,15 @@ static u32 pvid_to_extvid(struct drm_i91
 
 static void __i915_update_gfx_val(struct drm_i915_private *dev_priv)
 {
-	u64 now, diff, diffms;
+	struct timespec now, diff1;
+	u64 diff;
+	unsigned long diffms;
 	u32 count;
 
 	assert_spin_locked(&mchdev_lock);
 
-	now = ktime_get_raw_ns();
-	diffms = now - dev_priv->ips.last_time2;
-	do_div(diffms, NSEC_PER_MSEC);
+	getrawmonotonic(&now);
+	diff1 = timespec_sub(now, dev_priv->ips.last_time2);
 
 	/* Don't divide by 0 */
 	if (!diffms)
