1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1657,7 +1657,11 @@ int i915_driver_load(struct drm_device *
return 0;
out_gem_unload:
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
if (dev_priv->mm.inactive_shrinker.scan_objects)
+#else
+ if (dev_priv->mm.inactive_shrinker.shrink)
+#endif
unregister_shrinker(&dev_priv->mm.inactive_shrinker);
if (dev->pdev->msi_enabled)
@@ -1691,7 +1695,11 @@ int i915_driver_unload(struct drm_device
i915_teardown_sysfs(dev);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
if (dev_priv->mm.inactive_shrinker.scan_objects)
+#else
+ if (dev_priv->mm.inactive_shrinker.shrink)
+#endif
unregister_shrinker(&dev_priv->mm.inactive_shrinker);
mutex_lock(&dev->struct_mutex);
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -53,10 +53,15 @@ static void i915_gem_object_update_fence
struct drm_i915_fence_reg *fence,
bool enable);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
static unsigned long i915_gem_inactive_count(struct shrinker *shrinker,
struct shrink_control *sc);
static unsigned long i915_gem_inactive_scan(struct shrinker *shrinker,
struct shrink_control *sc);
+#else
+static int i915_gem_inactive_shrink(struct shrinker *shrinker,
+ struct shrink_control *sc);
+#endif
static long i915_gem_purge(struct drm_i915_private *dev_priv, long target);
static long i915_gem_shrink_all(struct drm_i915_private *dev_priv);
static void i915_gem_object_truncate(struct drm_i915_gem_object *obj);
@@ -4390,8 +4395,12 @@ i915_gem_load(struct drm_device *dev)
dev_priv->mm.interruptible = true;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
dev_priv->mm.inactive_shrinker.scan_objects = i915_gem_inactive_scan;
dev_priv->mm.inactive_shrinker.count_objects = i915_gem_inactive_count;
+#else
+ dev_priv->mm.inactive_shrinker.shrink = i915_gem_inactive_shrink;
+#endif
dev_priv->mm.inactive_shrinker.seeks = DEFAULT_SEEKS;
register_shrinker(&dev_priv->mm.inactive_shrinker);
}
@@ -4614,8 +4623,14 @@ static bool mutex_is_locked_by(struct mu
#endif
}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
static unsigned long
i915_gem_inactive_count(struct shrinker *shrinker, struct shrink_control *sc)
+#else
+#define SHRINK_STOP -1
+static int
+i915_gem_inactive_shrink(struct shrinker *shrinker, struct shrink_control *sc)
+#endif
{
struct drm_i915_private *dev_priv =
container_of(shrinker,
@@ -4624,7 +4639,12 @@ i915_gem_inactive_count(struct shrinker
struct drm_device *dev = dev_priv->dev;
struct drm_i915_gem_object *obj;
bool unlock = true;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
unsigned long count;
+#else
+ int nr_to_scan = sc->nr_to_scan;
+ int count;
+#endif
if (!mutex_trylock(&dev->struct_mutex)) {
if (!mutex_is_locked_by(&dev->struct_mutex, current))
@@ -4636,6 +4656,17 @@ i915_gem_inactive_count(struct shrinker
unlock = false;
}
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0))
+ if (nr_to_scan) {
+ nr_to_scan -= i915_gem_purge(dev_priv, nr_to_scan);
+ if (nr_to_scan > 0)
+ nr_to_scan -= __i915_gem_shrink(dev_priv, nr_to_scan,
+ false);
+ if (nr_to_scan > 0)
+ i915_gem_shrink_all(dev_priv);
+ }
+#endif
+
count = 0;
list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list)
if (obj->pages_pin_count == 0)
@@ -4649,6 +4680,7 @@ i915_gem_inactive_count(struct shrinker
return count;
}
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
static unsigned long
i915_gem_inactive_scan(struct shrinker *shrinker, struct shrink_control *sc)
{
@@ -4682,3 +4714,4 @@ i915_gem_inactive_scan(struct shrinker *
mutex_unlock(&dev->struct_mutex);
return freed;
}
+#endif
|