aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/i915/i915_gem_context.c54
1 files changed, 35 insertions, 19 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 06561213cf29..e664e869181f 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -198,6 +198,36 @@ void i915_gem_context_free(struct kref *ctx_ref)
198 kfree(ctx); 198 kfree(ctx);
199} 199}
200 200
201static struct drm_i915_gem_object *
202i915_gem_alloc_context_obj(struct drm_device *dev, size_t size)
203{
204 struct drm_i915_gem_object *obj;
205 int ret;
206
207 obj = i915_gem_alloc_object(dev, size);
208 if (obj == NULL)
209 return ERR_PTR(-ENOMEM);
210
211 /*
212 * Try to make the context utilize L3 as well as LLC.
213 *
214 * On VLV we don't have L3 controls in the PTEs so we
215 * shouldn't touch the cache level, especially as that
216 * would make the object snooped which might have a
217 * negative performance impact.
218 */
219 if (INTEL_INFO(dev)->gen >= 7 && !IS_VALLEYVIEW(dev)) {
220 ret = i915_gem_object_set_cache_level(obj, I915_CACHE_L3_LLC);
221 /* Failure shouldn't ever happen this early */
222 if (WARN_ON(ret)) {
223 drm_gem_object_unreference(&obj->base);
224 return ERR_PTR(ret);
225 }
226 }
227
228 return obj;
229}
230
201static struct i915_hw_ppgtt * 231static struct i915_hw_ppgtt *
202create_vm_for_ctx(struct drm_device *dev, struct intel_context *ctx) 232create_vm_for_ctx(struct drm_device *dev, struct intel_context *ctx)
203{ 233{
@@ -234,27 +264,13 @@ __create_hw_context(struct drm_device *dev,
234 list_add_tail(&ctx->link, &dev_priv->context_list); 264 list_add_tail(&ctx->link, &dev_priv->context_list);
235 265
236 if (dev_priv->hw_context_size) { 266 if (dev_priv->hw_context_size) {
237 ctx->obj = i915_gem_alloc_object(dev, dev_priv->hw_context_size); 267 struct drm_i915_gem_object *obj =
238 if (ctx->obj == NULL) { 268 i915_gem_alloc_context_obj(dev, dev_priv->hw_context_size);
239 ret = -ENOMEM; 269 if (IS_ERR(obj)) {
270 ret = PTR_ERR(obj);
240 goto err_out; 271 goto err_out;
241 } 272 }
242 273 ctx->obj = obj;
243 /*
244 * Try to make the context utilize L3 as well as LLC.
245 *
246 * On VLV we don't have L3 controls in the PTEs so we
247 * shouldn't touch the cache level, especially as that
248 * would make the object snooped which might have a
249 * negative performance impact.
250 */
251 if (INTEL_INFO(dev)->gen >= 7 && !IS_VALLEYVIEW(dev)) {
252 ret = i915_gem_object_set_cache_level(ctx->obj,
253 I915_CACHE_L3_LLC);
254 /* Failure shouldn't ever happen this early */
255 if (WARN_ON(ret))
256 goto err_out;
257 }
258 } 274 }
259 275
260 /* Default context will never have a file_priv */ 276 /* Default context will never have a file_priv */