This source file includes following definitions.
- i915_gem_throttle_ioctl
1
2
3
4
5
6
7 #include <linux/jiffies.h>
8
9 #include <drm/drm_file.h>
10
11 #include "i915_drv.h"
12 #include "i915_gem_ioctls.h"
13 #include "i915_gem_object.h"
14
15
16
17
18
19
20
21 #define DRM_I915_THROTTLE_JIFFIES msecs_to_jiffies(20)
22
23
24
25
26
27
28
29
30
31
32
33
34 int
35 i915_gem_throttle_ioctl(struct drm_device *dev, void *data,
36 struct drm_file *file)
37 {
38 struct drm_i915_file_private *file_priv = file->driver_priv;
39 unsigned long recent_enough = jiffies - DRM_I915_THROTTLE_JIFFIES;
40 struct i915_request *request, *target = NULL;
41 long ret;
42
43
44 ret = intel_gt_terminally_wedged(&to_i915(dev)->gt);
45 if (ret)
46 return ret;
47
48 spin_lock(&file_priv->mm.lock);
49 list_for_each_entry(request, &file_priv->mm.request_list, client_link) {
50 if (time_after_eq(request->emitted_jiffies, recent_enough))
51 break;
52
53 if (target) {
54 list_del(&target->client_link);
55 target->file_priv = NULL;
56 }
57
58 target = request;
59 }
60 if (target)
61 i915_request_get(target);
62 spin_unlock(&file_priv->mm.lock);
63
64 if (!target)
65 return 0;
66
67 ret = i915_request_wait(target,
68 I915_WAIT_INTERRUPTIBLE,
69 MAX_SCHEDULE_TIMEOUT);
70 i915_request_put(target);
71
72 return ret < 0 ? ret : 0;
73 }